SetTimer 回调函数失败,该怎么处理

   阅读
SetTimer 回调函数失败
VB.NET code

Option Explicit On
Module WinTimer

    Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Callback) As Integer
    Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long

    Public lngTimerID  As Long
    Delegate Sub Callback(ByVal hwnd As Integer, ByVal uMsg   As Integer, ByVal idEvent As Integer, ByVal dwTime As Integer)
    
    Public Sub TimeProcCallback(ByVal hwnd As Integer, ByVal uMsg As Integer, ByVal idEvent As Integer, ByVal dwTime As Integer)
   MessageBox.Show("ok")
    End Sub

End Module
'窗口内按钮单击事件调用
Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click

lngTimerID = SetTimer(0, 0, times, AddressOf TimeProcCallback)
End Sub



------解决方案--------------------
VB.NET code

    Public WriteAccess As Long
    Public Delegate Sub TimerEventHandler(ByVal uID As UInt32, ByVal uMsg As UInt32, ByRef dwUser As UInt32, ByVal dw1 As UInt32, ByVal dw2 As UInt32)
    Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As UInt32, ByVal uResolution As UInt32, ByVal lpFunction As TimerEventHandler, ByRef dwUser As UInt32, ByVal uFlags As UInt32) As UInt32
    Public Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As UInt32) As UInt32
    Public mTimerCallback As TimerEventHandler
阅读