-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
你真的需要问一个问题。特别是你有什么问题吗?似乎几分钟的研究会为您带来约95%的转化。然后你可以问一个关于你遇到什么问题的特定问题。 –
我在C#中使用正确的参数和数据类型在C#下面行编写时遇到了麻烦:'g_CTimer.TimerID = SetTimer(0&,0&,g_CTimer.Interval,AddressOf TimerProc)' – apratik
在C#中你不需要这样做,因为在.Net有几个'Timer'类的类已经可以做你在这里做的任何事情。我的意思是'VB6 - > C#'迁移不仅仅是翻译代码。您需要使用.Net类和OOP哲学进行完整重写。 –