各位大佬,如果知道某磁盤物理ID,怎么獲取它的協議版本、VID、PID等資訊呢?如果有知道,請幫一把,謝謝!
uj5u.com熱心網友回復:
https://blog.csdn.net/chenyujing1234/article/details/7577320uj5u.com熱心網友回復:
多謝了uj5u.com熱心網友回復:
大佬,能不能講一下,用那個介面獲取協議版本嗎?因為好像你給的鏈接上講的大概思路,沒有說那個介面介面獲取的欄位是表示協議版本?能不能給點提示呢?因為沒有積分,下載不了你給的鏈接的demouj5u.com熱心網友回復:
MS有提供一個USBView的例子代碼,可以參考一下~uj5u.com熱心網友回復:
找了,結果下載不成功……uj5u.com熱心網友回復:
https://docs.microsoft.com/zh-cn/windows-hardware/drivers/other-wdk-downloadsuj5u.com熱心網友回復:
請問我用IOCTL_GET_USB_DESCRIPTOR獲取設備描述符,為啥會報錯GetLastError 1,代碼如下: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, //default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL
);
MyPrintLog(_T("Disk:%s hDevice:%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, &number, sizeof(number), &dwBytes, NULL);
if (!nResult)
{
fprintf(stderr, "DeviceIoControl Error:%ld\n", GetLastError());
}
CString 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), &usbDevDesc, sizeof(usbDevDesc), &dwInDataSize, NULL);
if (!bRet)
{
strDebug.Format(_T("bRet:%d, Error:%ld"), bRet, GetLastError());
AfxMessageBox(strDebug);
}
strDebug.Format(_T("%04X"), usbDevDesc.bcdUSB);
AfxMessageBox(strDebug);
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/7381.html
標籤:硬件/系統
上一篇:VB實作資料記憶儲存
下一篇:activex視窗不顯示問題
