读书人

VB6.0怎么调用C++封装DLL中的回调函数

发布时间: 2012-03-29 12:53:12 作者: rapoo

VB6.0如何调用C++封装DLL中的回调函数?
现在普通函数可以正常调用,但是回调函数调用不起来.

[解决办法]

VB code
'''''' VB.Net调用DLL中接口函数,测试代码Import System.Runtime.InteropServicesPublic Class Form1'声明一个委托代理Delegate SUB myDelegate (Byval retVal AS Interger)'声明DLL中接口函数<DllImport ("test.dll", CharSet:=CharSet.ansi, CallingConvertinon:=CallingConvertion.Cdecl) > Public Shared Function getSum(Byval a as Integer, Byval b as Integer) AS Integer<DllImport ("test.dll", CharSet:=CharSet.ansi, CallingConvertinon:=CallingConvertion.Cdecl) > Public Shared Function testCallBack(Byval pfun as myDelegate) AS Long'回调方式接收消息Public SUB funCallBack(Byval ret AS Integer)MsgBox Now()print retEND SUBPrivate SUB Button1_Click(Byval sender AS System.Object, Byval e AS System.Eventargs) Handles Button1.ClickDim retVal AS IntegerretVal = getSum(5,6)Call testCallBack(Address Of funCallBack)END SUBEND Class 

读书人网 >VB

热点推荐