VB回调设置

前端之家收集整理的这篇文章主要介绍了VB回调设置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
In VC++
CPP文件:
#define DLLEXPORT		__declspec(dllexport) __stdcall
#define CNAME			extern "C"
typedef int	(__stdcall *CBFUNC)(int);
CNAME int DLLEXPORT F(CBFUNC p)
{
	return (*p)(10);
}
DEF文件:
LIBRARY DllTest
EXPORTS
	F

In VB
Form窗体:
Option Explicit
Private Sub Command1_Click()
    CallTest
End Sub
模块文件:
Option Explicit
Private Declare Function F _
        Lib "c:\DllTest.dll" ( _
            ByVal rt As Long _
) As Long
Private Function CallBackTest(ByVal q As Long) As Long
    CallBackTest = q * 10
End Function
Public Sub CallTest()
    MsgBox F(AddressOf CallBackTest)
End Sub
原文链接:https://www.f2er.com/vb/259423.html

猜你在找的VB相关文章