C#调用C++/CLI本地代码的回调函数
c++ dll
CClientGlobal.h
class __declspec(dllexport) CClientGlobal
{
public:
typedef int (*pMsgHandleResponseFunc)(CMsg*,vector<CMsg*>&);
typedef int (*pRequestTimeOutFunc)(int _CMDID);
void Set_Response(pMsgHandleResponseFunc fp){};
void Set_Timeout(pRequestTimeOutFunc fp){};
void Set_Response(void* p){};
void Set_Timeout(void* p){};
}
c++/cli wrapper 库
native head
CClientGlobal.h
class __declspec(dllexport) CClientGlobal
{
public:
typedef int (*pMsgHandleResponseFunc)(CMsg*,vector<CMsg*>&);
typedef int (*pRequestTimeOutFunc)(int _CMDID);
void Set_Response(pMsgHandleResponseFunc fp){};
void Set_Timeout(pRequestTimeOutFunc fp){};
void Set_Response(void* p){};
void Set_Timeout(void* p){};
}
wrapper head
public ref class CClientGlobalWrapper
{
CClientGlobal* NativeClientGlobal;
public:
CClientGlobalWrapper(void);
~CClientGlobalWrapper();
public: //消息发送
typedef int (*pMsgHandleResponseFunc)(CMsg*,vector<CMsg*>&);
typedef int (*pRequestTimeOutFunc)(int _CMDID);
void Set_Response(void* fp);
void Set_Response(pMsgHandleResponseFunc fp);
void Set_Timeout(void* fp);
void Set_Timeout(pRequestTimeOutFunc fp);
};
我没有使用显示声明dll函数的方式,而是在C#中添加C++/cli封装的dll,
CClientGlobalWrapper cgw = new CClientGlobalWrapper();
pMsgHandleResponseFunc msgh = new pMsgHandleResponseFunc(MsgHandle);
cgw.Set_Response() 方法只能看到void*的参数,而看不到函数指针的参数
有没有兄弟有这方面经验的,请帮忙解决一下