一、C++端
1、声明Receive函数原型
typedef bool (CALLBACK *Receive)(unsigned char *pBuf, int width, int height, int channel, int stride,int user);
2、回复信息的回调函数
Receive m_RecInfoCall;
3、//设置回调函数-----注册回调函数
extern "C" __declspec(dllexport) bool WINAPI SetCallback(Receive InfoReceive)
4、
//调用函数
extern "C" __declspec(dllexport) void __stdcall Use()
二、C#端
1、建立C++的动态库对应的委托
[DllImport("CppDll.dll", EntryPoint = "Use")] //"WebService.dll"为dll名称,UserLogin 为函数名
2、建立回调函数调用的委托
static extern void Use();
3、建立回调函数委托
public delegate void MyDllCall(IntPtr buffer, int col, int row, int channel, int stride,int user);
4、设置回调函数
[DllImport("CppDll.dll", EntryPoint = "SetCallback")]
static extern bool SetCallback(MyDllCall fa);
5、回调函数声明
public void FunA(IntPtr buffer, int col, int row, int channel, int stride,int user)
6、调用
SetCallback(FunA);
Use();