其中回调函数为 RenderCallback p_func
[DllImport("xjsdk.dll", EntryPoint = "XJSdkInit", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern int XJSdkInit(string p_enterise_id, string p_settings, string p_device_infos, string p_server_url, RenderCallback p_func);
1定义委托类:
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void RenderCallback(int event_type, string p_data);
public static RenderCallback RemoteMsgCallBack;
public static void RegistRemoteMsgCallBack(string p_enterise_id, string p_settings, string p_device_infos, string p_server_url, RenderCallback p_func)
{
XJSdkInit(p_enterise_id, p_settings, p_device_infos, p_server_url, RemoteMsgCallBack);
}
程序端调用方法:
DllBaseSDK.RemoteMsgCallBack = CallBackFunction;
DllBaseSDK.RegistRemoteMsgCallBack(Mmsg.QiyeId, Mmsg.SBName, MsgAll, Url, CallBackFunction);
也可以是这样的:
public RenderCallback globalCallbackProcedure;
globalCallbackProcedure = new RenderCallback(CallBackFunction);
DllBaseSDK.RegistRemoteMsgCallBack(Mmsg.QiyeId, Mmsg.SBName, MsgAll, Url, globalCallbackProcedure );
|