|
USB Bulk设备 DeviceIoControl用自己的VendorCmd怎么总是返回错误6 (Invalid Handler)?
[复制链接]
大虾帮帮忙,我的CreateFile有错么??? (人家怎么有直接打开"\\\\.\\IOCTL"??? 这是什么设备?)
为什么DeviceIoControl总是说Handle不对???
而且这个DeviceIoControl没看到在对应的WDM驱动中走到 BulkUsb_DispatchDevCtrl()处理函数,是在上层就被退回来了?
hFile = CreateFile( m_DeviceName,//"\\?\usb#vid_10c4&pid_0003#5&1d4952dc&0&2#{37538c66-9584-42d3-9632-ebad0a230d13}"
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
#define MY_USB_VENDOR_IOCTL_FUNC_BASE 0x0800
#define IOCTL_MY_USB_VENDOR_IOCTL_CMD1 CTL_CODE(FILE_DEVICE_UNKNOWN, \
MY_USB_VENDOR_IOCTL_FUNC_BASE+1, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
char cArrTmp[4/*64*/] = {0x0};
int length, numBytesReceived;
BOOL bResult = DeviceIoControl ( // Perform the Vendor Specific Command IOCTL.
cyHandle,
IOCTL_MY_USB_VENDOR_IOCTL_CMD1,
NULL,
0,
&cArrTmp,
sizeof(cArrTmp),//length,
(LPDWORD) &numBytesReceived,
NULL );
if (bResult == TRUE)
{
status = F32x_SUCCESS;//return SUCCESS;
}
else
{
status = F32x_INVALID_HANDLE;//return FAILURE;
//#define ERROR_INVALID_HANDLE 6L //winerror.h
strTmp.Format("Error %d in IOCTL_INTUSB_GET_CONFIG_DESCRIPTOR call\n", //Error 6 !!!!
GetLastError());
}
|
|