首页 > 代码库 > VB6的函数指针传递
VB6的函数指针传递
Option ExplicitPrivate Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPublic Type MySubParams ID As Long Name As StringEnd TypeSub MySub1(p As MySubParams, a As Long, b As Long, c As Long) Debug.Print VarPtr(p) MsgBox "MySub1 " & p.ID & " " & p.NameEnd SubSub MySub2(p As MySubParams, a As Long, b As Long, c As Long) Debug.Print VarPtr(p) MsgBox "MySub2 " & p.ID & " " & p.NameEnd SubFunction CallSub(address As Long, params As Long) CallSub = CallWindowProc(address, params, 0&, 0&, 0&)End FunctionSub Start() Dim a As Long Dim p As MySubParams p.ID = 1 p.Name = "Test1" Debug.Print VarPtr(p) Debug.Print CallSub(AddressOf MySub1, VarPtr(p)) p.ID = 2 p.Name = "Test2" Debug.Print CallSub(AddressOf MySub2, VarPtr(p))End Sub
VB6的函数指针传递
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。