阅读:1115回复:0
vc编程,createfile无法实现?请进
cy7c68013,板子驱动已经下载了,开发包的通用驱动,用control panel可以得到设备描述符,但是我用vc自己写的如下程序,无法实现createfile,为什么呢?请各位大虾帮忙看看,谢谢
void CUsbhostDlg::OnDeviceButton() { // TODO: Add your control notification handler code here USB_DEVICE_DESCRIPTOR output; HANDLE hDevice; BOOL bResult; ULONG nBytes=0; CString str; hDevice=CreateFile(\"\\\\\\\\.\\\\ezusb-0\",GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL); if (INVALID_HANDLE_VALUE==hDevice) { MessageBox(\"无效设备,请重试!\", \"错误\", MB_ICONERROR | MB_OK); } else { MessageBox(\"create done\", \"正确\", MB_ICONERROR | MB_OK); } bResult = DeviceIoControl (hDevice, IOCTL_Ezusb_GET_DEVICE_DESCRIPTOR, NULL, 0, &output, sizeof(output), &nBytes, NULL); if (!bResult) { MessageBox(\"读取设备描述符失败!\", \"错误\", MB_ICONERROR | MB_OK); } else { m_UsbList.AddString(\"USB Device Descriptor\"); str.Format(_T(\"bLength:0x%x\"),output.bLength); m_UsbList.AddString(str); str.Format(_T(\"bDescriptorType:0x%x\"),output.bDescriptorType); m_UsbList.AddString(str); str.Format(_T(\"bcdUSB:0x%x\"),output.bcdUSB); m_UsbList.AddString(str); str.Format(_T(\"bDeviceClass:0x%x\"),output.bDeviceClass); m_UsbList.AddString(str); str.Format(_T(\"bDeviceSubClass:0x%x\"),output.bDeviceSubClass); m_UsbList.AddString(str); str.Format(_T(\"bDeviceProtocol:0x%x\"),output.bDeviceProtocol); m_UsbList.AddString(str); str.Format(_T(\"bMaxPacketSize0:0x%x\"),output.bMaxPacketSize0); m_UsbList.AddString(str); str.Format(_T(\"idVendor:0x%x\"),output.idVendor); m_UsbList.AddString(str); str.Format(_T(\"idProduct:0x%x\"),output.idProduct); m_UsbList.AddString(str); str.Format(_T(\"bcdDevice:0x%x\"),output.bcdDevice); m_UsbList.AddString(str); str.Format(_T(\"iManufacturer:0x%x\"),output.iManufacturer); m_UsbList.AddString(str); str.Format(_T(\"iProduct:0x%x\"),output.iProduct); m_UsbList.AddString(str); str.Format(_T(\"iSerialNumber:0x%x\"),output.iSerialNumber); m_UsbList.AddString(str); str.Format(_T(\"bNumConfigurations:0x%x\"),output.bNumConfigurations); m_UsbList.AddString(str); } CloseHandle (hDevice); } |
|