vc注册回调函数RegisterStreamDirectReadCallback
DLLEXPORT_API
int __stdcall RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback,void *Context); 回调函数定义如下:
typedef int (*STREAM_DIRECT_READ_CALLBACK)(ULONG channelNumber,void *DataBuf,DWORD Length,int FrameType,void *context); 需要在C#里面通过Marshal实现这两个函数,对于第一个注册函数,定义如下: [DllImport("DS40xxSDK.dll")]
public static extern short RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback, IntPtr Context); 回调函数用Delegate定义如下: public delegate short STREAM_DIRECT_READ_CALLBACK( uint channelNumber, IntPtr DataBuf,uint Length,int FrameType,IntPtr Context); 然后实现函数定义如下: public unsafe short StreamDirectReadCallback(uint channelNumber, IntPtr DataBuf,uint Length,int frameType,IntPtr Context){} 最后调用的时候回调的确成功了,调用如下:
RegisterStreamDirectReadCallback(new STREAM_DIRECT_READ_CALLBACK (this.StreamDirectReadCallback ),new IntPtr (0));
但是当回调函数结束以后报错."Ox00000007"指令引用的"Ox00000007"内存。该内存不能为"read".
DLLEXPORT_API
int __stdcall RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback,void *Context); 回调函数定义如下:
typedef int (*STREAM_DIRECT_READ_CALLBACK)(ULONG channelNumber,void *DataBuf,DWORD Length,int FrameType,void *context); 需要在C#里面通过Marshal实现这两个函数,对于第一个注册函数,定义如下: [DllImport("DS40xxSDK.dll")]
public static extern short RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback, IntPtr Context); 回调函数用Delegate定义如下: public delegate short STREAM_DIRECT_READ_CALLBACK( uint channelNumber, IntPtr DataBuf,uint Length,int FrameType,IntPtr Context); 然后实现函数定义如下: public unsafe short StreamDirectReadCallback(uint channelNumber, IntPtr DataBuf,uint Length,int frameType,IntPtr Context){} 最后调用的时候回调的确成功了,调用如下:
RegisterStreamDirectReadCallback(new STREAM_DIRECT_READ_CALLBACK (this.StreamDirectReadCallback ),new IntPtr (0));
但是当回调函数结束以后报错."Ox00000007"指令引用的"Ox00000007"内存。该内存不能为"read".
[DllImport("DS40xxSDK.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern short RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback, IntPtr Context);