Home > Software engineering >  MFC get version of the USB protocol, VID and PID and other information
MFC get version of the USB protocol, VID and PID and other information

Time:11-06

, ladies and gentlemen, if you know a disk physical ID, how to obtain its protocol version, VID and PID and other information? If you have know, please help, thank you!

CodePudding user response:

https://blog.csdn.net/chenyujing1234/article/details/7577320

CodePudding user response:

reference 1st floor dd_zhouqian response:
https://blog.csdn.net/chenyujing1234/article/details/7577320
thanks a lot

CodePudding user response:

reference 1st floor dd_zhouqian response:
https://blog.csdn.net/chenyujing1234/article/details/7577320
, can you tell me the, use the interface to get the agreement version? Because if you give a link in the general idea, did not say the interface interface to get field is said protocol version? Can you give some tips? Because there is no integral, cannot download the link you gave the demo

CodePudding user response:

MS has provided an example of a USBView code, can refer to the ~

CodePudding user response:

reference 4 floor 7-eleven's response:
MS offer a USBView example code, you can consult ~
search and download the result is not successful...

CodePudding user response:

https://docs.microsoft.com/zh-cn/windows-hardware/drivers/other-wdk-downloads

CodePudding user response:

refer to 6th floor zgl7903 response:
https://docs.microsoft.com/zh-cn/windows-hardware/drivers/other-wdk-downloads
with IOCTL_GET_USB_DESCRIPTOR device descriptor, excuse me I why complains GetLastError 1, the code is as follows:

TCHAR diskPath [DISK_PATH_LEN];
Swprintf_s (diskPath, _T (" \ \ \ \. \ \ PhysicalDrive % d "), Disk).
HANDLE hDevice=CreateFile (
DiskPath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,//the default security attributes
OPEN_EXISTING,//disposition
0,//the file attributes
NULL
);
MyPrintLog (_T (" hDevice Disk: % s: % ld "), diskPath, hDevice);
If (hDevice==INVALID_HANDLE_VALUE)
{
Fprintf (stderr, "CreateFile Error: % ld \ n", GetLastError ());
}
DWORD dwBytes;
STORAGE_DEVICE_NUMBER number;
Int nResult=DeviceIoControl (hDevice, IOCTL_STORAGE_GET_DEVICE_NUMBER,
NULL, 0, & amp; Number, sizeof (number), & amp; DwBytes, NULL);
if (! NResult)
{
Fprintf (stderr, "DeviceIoControl Error: % ld \ n", GetLastError ());
}

Cstrings strDebug;
USBSCAN_GET_DESCRIPTOR getUsbDesc={0};
GetUsbDesc. DescriptorType=USB_DEVICE_DESCRIPTOR_TYPE;
GetUsbDesc. Index=1;
GetUsbDesc. LanguageId=0;

USB_DEVICE_DESCRIPTOR usbDevDesc={0};
DWORD dwInDataSize;
Bool bRet=DeviceIoControl (hdstDisk IOCTL_GET_USB_DESCRIPTOR,
& GetUsbDesc, sizeof (USBSCAN_GET_DESCRIPTOR), & amp; UsbDevDesc, sizeof (usbDevDesc), & amp; DwInDataSize, NULL);

if (! BRet)
{
StrDebug. The Format (_T (" bRet: % d, Error: % ld "), bRet, GetLastError ());
AfxMessageBox (strDebug);
}
StrDebug. The Format (_T (" % 4 x "), usbDevDesc. BcdUSB);
AfxMessageBox (strDebug);
  • Related