注冊(cè) 登錄
Office中國論壇/Access中國論壇 返回首頁

的個(gè)人空間 http://m.mzhfr.cn/?0 [收藏] [復(fù)制] [分享] [RSS]

日志

API 設(shè)置調(diào)整系統(tǒng)當(dāng)前時(shí)間

已有 3067 次閱讀2008-4-28 13:36 |個(gè)人分類:API

對(duì)于時(shí)間要求比較嚴(yán)謹(jǐn)?shù)那闆r下,需要對(duì)當(dāng)前系統(tǒng)時(shí)間和外部時(shí)間作一個(gè)對(duì)比,并作相應(yīng)的調(diào)整,這就要求能對(duì)系統(tǒng)時(shí)間重新設(shè)置

CODE:


'**************************************************
'
' 功能: 重新設(shè)置系統(tǒng)時(shí)間
' 用法: SetTime "2008-4-26 22:53:48"
' 作者: andymark
'  QQ : 42503577 ; Email: ewang11@163.com
' 備注:
'
'**************************************************
'設(shè)置當(dāng)前系統(tǒng)時(shí)間
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
End Type

'時(shí)區(qū)
Private Type TIME_ZONE_INFORMATION
        Bias As Long
        StandardName(32) As Integer
        StandardDate As SYSTEMTIME
        StandardBias As Long
        DaylightName(32) As Integer
        DaylightDate As SYSTEMTIME
        DaylightBias As Long
End Type

Public Sub SetTime(NewTime As String)
' 功能: 設(shè)置系統(tǒng)時(shí)間
   Dim lpSystemTime As SYSTEMTIME               '時(shí)間信息
   Dim ZoneNum As Integer
    ZoneNum = getZoneNum()
    With lpSystemTime
        .wYear = Year(NewTime)
        .wMonth = Month(NewTime) + 1
        .wDayOfWeek = -1
        .wDay = Day(NewTime)
        .wHour = Hour(NewTime) + ZoneNum
        .wMinute = Minute(NewTime)
        .wSecond = Second(NewTime)
        .wMilliseconds = 0
    End With
   
   SetSystemTime lpSystemTime
End Sub
Private Function getZoneNum() As Integer
    Dim lpSystemZone As TIME_ZONE_INFORMATION    '時(shí)區(qū)信息
    GetTimeZoneInformation lpSystemZone
    getZoneNum = lpSystemZone.Bias / 60
End Function
   

評(píng)論 (0 個(gè)評(píng)論)

facelist doodle 涂鴉板

您需要登錄后才可以評(píng)論 登錄 | 注冊(cè)

QQ|站長郵箱|小黑屋|手機(jī)版|Office中國/Access中國 ( 粵ICP備10043721號(hào)-1 )  

GMT+8, 2025-7-13 07:36 , Processed in 0.064568 second(s), 14 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回頂部