日期:2014-05-18  浏览次数:20971 次

调用dll时如何定义回调函数
C++下调用以下函数
C/C++ code

int __stdcall DVSNET_SearchServers(unsigned long dwWaitTime,unsigned long dwTimes,SearchNotify pNotify,void *pcontext,const char *sLocalUrl = NULL);


其中SearchNotify参数是一个回调函数
C/C++ code

typedef void (__stdcall *SearchNotify)(int nDevType,const char *sServName,const char *sServSerial,const char *sUrl,unsigned char MacAddr[6],unsigned short wWebPort,unsigned short wDataPort,
                    const char *sSubNetMask,const char *sGateWay,const char *sMultiIp,const char *sDNS,unsigned short wMultiPort,int nChCount,unsigned long bDHCP,void *pcontext);



请问在c#中该如何声明拼使用这个回调函数?



------解决方案--------------------
用委托,例如:
delegate void SearchNotify();
SearchNotify pNotify;
------解决方案--------------------
delegate void SearchNotify(int nDevType,string sServName,string sServSerial,string sUrl,[MarshalAs(UnmanagedType.LPArray, SizeConst = 6)]byte[] MacAddr,UInt16 wWebPort,UInt16 wDataPort,string sSubNetMask,string sGateWay,string sMultiIp,string sDNS,UInt16 wMultiPort,int nChCount,UInt64 bDHCP,IntPtr pcontext);
------解决方案--------------------
http://wenku.baidu.com/view/9f2ef117a216147917112813.html?st=1
------解决方案--------------------
看一下这个里面的资料。希望对你有帮助。http://wenku.baidu.com/view/9f2ef117a216147917112813.html?st=1