vb.net 系统API回调 & 动态调用API
这是一篇旧文档
一个回调函数的演示:
Public Class frmMain
Declare Function SetTimer Lib "user32" (ByVal hwnd As Int32, ByVal nIDEvent As Int32, ByVal uElapse As Int32, ByVal lpTimerFunc As TP) As Int32
Declare Function KillTimer Lib "user32" (ByVal hwnd As Int32, ByVal nIDEvent As Int32) As Int32
Delegate Function TP(ByVal hwnd As Int32, ByVal nIDEvent As Int32, ByVal uElapse As Int32, ByVal lpTimerFunc As Int32) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SetTimer(Me.Handle, 0, 1, AddressOf TimerProc)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
KillTimer(Me.Handle, 0)
End Sub
Dim i As Integer = 0
Function TimerProc(ByVal hwnd As Int32, ByVal nIDEvent As Int32, ByVal uElapse As Int32, ByVal lpTimerFunc As Int32) As Integer
i += 1
Me.Text = i
End Function
End Class
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。