过程参数传递的问题,请高手帮忙解决。

nkzyf 2005-02-23 03:33:23
vc的一个函数:
BOOL ReadWriteUsbPipe( HANDLE hDeviceHandle, //handle
int hPipeIndex, //pipe index
BOOL blRead, //read or write.TRUE is read
BYTE * hDataBuffer, //data buffer
int hDataLength, //data length:flow down
ULONG * pRetLen, //return length
BOOL * IsTimeOut //TimeOut??
)
/*
返回值:返回操作是否成功
hDeviceHandle: USB设备句柄
pRetLen: 返回数据数量
IsTimeOut: 是否超时
hDataLength: 下写的数据个数
blRead:yes: 读
hPipeIndex: 对应Dsp中定义的管道数组的索引号
hDataBuffer: 传入数据和传出数据缓存
*/
{
//DWORD count;
BYTE * buffer;
int status;
buffer=(BYTE *)malloc(sizeof(ULONG)+hDataLength);
*((ULONG*)(&(buffer[ 0 ]))) = hPipeIndex;
* IsTimeOut=FALSE;
if( !blRead ) //if write
{
if(hDataLength>0)
{
memcpy(&( buffer[ sizeof( ULONG ) ] ), hDataBuffer, hDataLength );
}

if( !(status=DeviceIoControl( hDeviceHandle,
IOCTL_Head_BULK_WRITE,
buffer,
hDataLength+sizeof(ULONG),
buffer,//NULL,
hDataLength+sizeof(ULONG),//0,
pRetLen,
NULL )))
{
free (buffer);
return FALSE;
}
if(0!=*(unsigned char * )buffer)
{
* IsTimeOut=TRUE;
}
}
else //if read
{
if( !(status=DeviceIoControl(hDeviceHandle,
IOCTL_Head_BULK_OR_INTERRUPT_READ,
buffer,
hDataLength+sizeof(ULONG),
buffer,
hDataLength+sizeof(ULONG),
pRetLen,
NULL )))
{
free (buffer);
return FALSE;
}else{
if(0!=*(unsigned char * )buffer)
{
* IsTimeOut=TRUE;
}
if( hDataBuffer != NULL )
memcpy( hDataBuffer,
&( buffer[ sizeof( ULONG ) ] ),
hDataLength );
}
}
free(buffer);
*pRetLen -=4;
return TRUE;
}

把它做成com的一个过程,加入后得到的过程为:
procedure TUSB.ReadWriteUsbPipe(hDeviceHandle: Integer; hPipeIndex: SYSINT; blRead:Integer;
var hDataBuffer: Byte; hDataLength: SYSINT; var pRetLen: LongWord;
var IsTimeOut: Integer; result: Integer);

请问,我在调用这个过程时,第四个参数(hDatabuffer)和第五个(hDataLenth)如何传递?
应该传哪种类型的参数?
...全文
67 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
djmdjmdjm 2005-02-24
  • 打赏
  • 举报
回复
没看懂问的是什么(水平有限)
nkzyf 2005-02-24
  • 打赏
  • 举报
回复
自己顶一下

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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