對(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 [/code] 詳細(xì)內(nèi)容:http://m.mzhfr.cn/forum.php?mod=viewthread&tid=61472 |
|站長(zhǎng)郵箱|小黑屋|手機(jī)版|Office中國(guó)/Access中國(guó)
( 粵ICP備10043721號(hào)-1 )
GMT+8, 2025-7-13 08:18 , Processed in 0.055885 second(s), 16 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.