'Declare Function SetSystemTime Lib "kernel32" Alias "SetSystemTime" (lpSystemTime As SYSTEMTIME) As Long'The SetSystemTime function sets the current system time and date. 'The system time is expressed in Coordinated Universal Time (UTC).Private 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 Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long Private Sub Form_Load() 'KPD-Team 2000 'URL: http://www.allapi.net/ 'E-Mail: [email protected] Dim lpSystemTime As SYSTEMTIME lpSystemTime.wYear = 2000 lpSystemTime.wMonth = 1 lpSystemTime.wDayOfWeek = -1 lpSystemTime.wDay = 24 lpSystemTime.wHour = 23 lpSystemTime.wMinute = 26 lpSystemTime.wSecond = 0 lpSystemTime.wMilliseconds = 0 'set the new time SetSystemTime lpSystemTime End Sub
那你说一下怎么锁嘛,让CPU的时钟不转? 为什么要锁定它呢?
Private lBegin As Long, lEnd As Long Private BeginTime, EndTime Private Declare Function GetCurrentTime Lib "kernel32" Alias "GetTickCount" () As LongPublic Sub InitCheckTime() BeginTime = Time lBegin = GetCurrentTime End SubPublic Sub CheckTime() Dim Inter1 As Single, Inter2 As Single EndTime = Time lEnd = GetCurrentTime Inter1 = (lEnd - lBegin) / 1000 Inter2 = DateDiff("s", BeginTime, EndTime) If Abs(Inter1 - Inter2) >= 3 Then EndTime = DateAdd("s", Inter1, BeginTime) Time = EndTime End If End Sub在Form_Load里调用InitCheckTime,加一个Timer控件,在其中调用CheckTime即可实现系统时间的自动校正,防止用户更改系统时间。是我说的意思吗?
'The system time is expressed in Coordinated Universal Time (UTC).Private 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
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim lpSystemTime As SYSTEMTIME
lpSystemTime.wYear = 2000
lpSystemTime.wMonth = 1
lpSystemTime.wDayOfWeek = -1
lpSystemTime.wDay = 24
lpSystemTime.wHour = 23
lpSystemTime.wMinute = 26
lpSystemTime.wSecond = 0
lpSystemTime.wMilliseconds = 0
'set the new time
SetSystemTime lpSystemTime
End Sub
为什么要锁定它呢?
Private BeginTime, EndTime
Private Declare Function GetCurrentTime Lib "kernel32" Alias "GetTickCount" () As LongPublic Sub InitCheckTime()
BeginTime = Time
lBegin = GetCurrentTime
End SubPublic Sub CheckTime()
Dim Inter1 As Single, Inter2 As Single
EndTime = Time
lEnd = GetCurrentTime
Inter1 = (lEnd - lBegin) / 1000
Inter2 = DateDiff("s", BeginTime, EndTime)
If Abs(Inter1 - Inter2) >= 3 Then
EndTime = DateAdd("s", Inter1, BeginTime)
Time = EndTime
End If
End Sub在Form_Load里调用InitCheckTime,加一个Timer控件,在其中调用CheckTime即可实现系统时间的自动校正,防止用户更改系统时间。是我说的意思吗?