阅读:2222回复:6
为何我的DEVICEIOCONTROL总是说我参数错?我哪儿错了
int WritePort(UCHAR Port,UCHAR Value)
{ DWORD dwResult = 0; UCHAR PV[2] = {Port,Value}; if (!DeviceIoControl(hDevice, EVENT_WRITEPORT, &PV, 2, NULL, 0, &dwResult, NULL) ) return GetLastError(); return 0; } GetLastError()总是返回87,查MSDN说是参数错,我哪用错了啊???? EVENT_WRITEPORT是我用DRIVERSTUDIO向导时加的,定义为 #define EVENT_WRITEPORT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS) |
|
沙发#
发布于:2004-01-07 12:08
将 2 改成strlen(pv) 8试试
|
|
板凳#
发布于:2004-01-07 12:16
试过了,还试过2*sizeof(UCHAR),感觉不象只是单纯 的参数错那么简单,是不是整个驱动程序哪有问题
|
|
地板#
发布于:2004-01-07 12:31
甚至我用
if (!DeviceIoControl(hDevice, EVENT_CLOSE, NULL, 0 NULL, 0, &dwResult, NULL) ) return GetLastError(); GetLastError()也是说87错,我要疯了,大家帮帮我吧 |
|
地下室#
发布于:2004-01-07 13:28
倒数第二个参数好像有问题,(摘字msdn)
If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation produces no output data, and lpOutBuffer can be NULL, DeviceIoControl makes use of the variable pointed to by lpBytesReturned. After such an operation, the value of the variable is without meaning. If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this is an overlapped operation, you can get the number of bytes returned by calling GetOverlappedResult. If hDevice is associated with an I/O completion port, you can get the number of bytes returned by calling GetQueuedCompletionStatus. 试试~_~ |
|
5楼#
发布于:2004-01-07 15:07
啊,我真是猪头,我把DRV下DEVICE函数对应SWITCH的操作给删了,原来会这样报错。。。。。
|
|
6楼#
发布于:2004-01-14 10:17
第一个帖子的参数也不对吧,&PV?PV?
|
|
|