又一个API调用写法的问题,大家来帮帮我!!!!

szj820 2006-08-17 03:46:28
标准函数说明如下,在C#中怎么写????用DLLImport

函数:int RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback, void* Context)
参数:STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback 数据流准备好时会调用该函数
Void * Context 调用回调函数时提供的上下文

回调函数说明:STREAM_DIRECT_READ_CALLBACK (ULONG channelNumber,void* DataBuf,DWORD Length,int FrameType, void* context)
ULONG channelNumber 通道号
Void * DataBuf 缓冲区地址
DWORD Length 缓冲区长度
int FrameType 缓冲区帧类型
void * context 设备上下文

返回:正确为0,其他为第4节定义的错误号;
说明:DS4000HC卡新增一种数据流读取方式,当启动数据捕获后,StreamDirectReadCallback会提
供数据流的地址、长度、帧类型等,用户程序直接处理。
...全文
202 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
szj820 2006-08-17
  • 打赏
  • 举报
回复
555555555
不是我不试着去写,我不懂C++,看不明白,现在在写外调函数库,还有几十个函数呢,目前也没法测试,没办法,谢谢了!!!!
Knight94 2006-08-17
  • 打赏
  • 举报
回复
这次帮你了,下次自己要试着仿写,如果不行的话,再提出问题,这样有助于你提高。

public delegate void DrawFun( int nPort, IntPtr hDc, int nUser );

[DllImport(...)]
public extern static int RegisterDrawFun( uint nport, DrawFun myDrawFun, int nUser );
szj820 2006-08-17
  • 打赏
  • 举报
回复
又有一个搞不定了,帮我看看

函数:int RegisterDrawFun(DWORD nport,DRAWFUN(DrawFun),LONG nUser)
参数:DWORD nport 通道号索引
DRAWFUN(DrawFun) 回调函数句柄
LONG nUser 用户数据

回调函数说明: void CALLBACK DrawFun(LONG nPort,HDC hDc,LONG nUser)
nPort 通道号
hDc OffScreen表面设备上下文,相当于显示窗口中的DC
nUser 用户数据

返回: 正确为0,其他为第4节定义的错误号;
Knight94 2006-08-17
  • 打赏
  • 举报
回复
Call it as follows:

//you should define a callback function
private void MyCALLBACK( uint channelNumber, IntPtr DataBuf, uint Length, int FrameType, IntPtr context)
{
//Do some operation in the callback function
}

//call
RegisterStreamDirectReadCallback( new STREAM_DIRECT_READ_CALLBACK( MyCALLBACK ),
yourConText );
Knight94 2006-08-17
  • 打赏
  • 举报
回复
Have a try!

public delegate void STREAM_DIRECT_READ_CALLBACK( uint channelNumber, IntPtr DataBuf, uint Length, int FrameType, IntPtr context);

[DllImport( ... ) ]
public extern static int RegisterStreamDirectReadCallback( STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback, IntPtr Context );

111,131

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧