-4
Option Explicit  
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long    

Function TimerCreate() As Boolean

    If g_CTimer Is Nothing Then Exit Function

    ' Create the timer
    g_CTimer.TimerID = SetTimer(0&, 0&, g_CTimer.Interval, AddressOf TimerProc)
    If g_CTimer.TimerID Then
        TimerCreate = True
    Else
        TimerCreate = False
        g_CTimer.TimerID = 0
     End If   
End Function  

Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
    On Error Resume Next

    If g_CTimer Is Nothing Then Exit Sub
    g_CTimer.ThatTime
End Sub
4

1 回答 1

1

对于计时器,您可能想要:

System.Threading.Timer myTimer =
    new System.Threading.Timer(TimerProc, null, g_CTimer.Interval, g_CTimer.Interval);

请参阅System.Threading.Timer

如果您真的需要使用多媒体计时器(我不推荐),我建议您阅读Windows 计时器并查看 pinvoke.net 以获取托管原型。例如,SetTimer

于 2013-07-25T19:49:31.823 回答