慕运维8079593
对于Win64,我需要将其更改为:Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong, ByVal uElapse As LongLong, ByVal lpTimerfunc As LongLong) As LongLongDeclare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong) As LongLongPublic TimerID As LongLong 'Need a timer ID to eventually turn off the timer. If the timer ID <> 0 then the timer is runningPublic Sub TriggerTimer(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long) MsgBox "The TriggerTimer function has been automatically called!"End SubPublic Sub DeactivateTimer()Dim lSuccess As LongLong lSuccess = KillTimer(0, TimerID) If lSuccess = 0 Then MsgBox "The timer failed to deactivate." Else TimerID = 0 End IfEnd SubPublic Sub ActivateTimer(ByVal nMinutes As Long) nMinutes = nMinutes * 1000 * 60 'The SetTimer call accepts milliseconds, so convert to minutes If TimerID <> 0 Then Call DeactivateTimer 'Check to see if timer is running before call to SetTimer TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer) If TimerID = 0 Then MsgBox "The timer failed to activate." End IfEnd Sub
12345678_0001
更正64位的上限答案:Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong, ByVal uElapse As LongLong, ByVal lpTimerfunc As LongLong) As LongLongDeclare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong) As LongLongPublic TimerID As LongLong 'Need a timer ID to eventually turn off the timer. If the timer ID <> 0 then the timer is runningPublic Sub TriggerTimer(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long) MsgBox "The TriggerTimer function has been automatically called!"End SubPublic Sub DeactivateTimer()Dim lSuccess As LongLong '<~ Corrected here lSuccess = KillTimer(0, TimerID) If lSuccess = 0 Then MsgBox "The timer failed to deactivate." Else TimerID = 0 End IfEnd SubPublic Sub ActivateTimer(ByVal nMinutes As Long) nMinutes = nMinutes * 1000 * 60 'The SetTimer call accepts milliseconds, so convert to minutes If TimerID <> 0 Then Call DeactivateTimer 'Check to see if timer is running before call to SetTimer TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer) If TimerID = 0 Then MsgBox "The timer failed to activate." End IfEnd Sub