C++/Is Usb Device Edit Diff Refresh Backlink Random Search History Help Setting Hide Show BOOL IsUsbDevice(TCHAR letter) { TCHAR volumeAccessPath[] = _T("\\\\.\\X:"); volumeAccessPath[4] = letter; HANDLE deviceHandle = CreateFile( volumeAccessPath, 0, // no access to the drive FILE_SHARE_READ | // share mode FILE_SHARE_WRITE, NULL, // default security attributes OPEN_EXISTING, // disposition 0, // file attributes NULL); // do not copy file attributes // setup query STORAGE_PROPERTY_QUERY query; memset(&query, 0, sizeof(query)); query.PropertyId = StorageDeviceProperty; query.QueryType = PropertyStandardQuery; // issue query DWORD bytes; STORAGE_DEVICE_DESCRIPTOR devd; STORAGE_BUS_TYPE busType = BusTypeUnknown; if (DeviceIoControl(deviceHandle, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(query), &devd, sizeof(devd), &bytes, NULL)) { busType = devd.BusType; } else { //std::wcout << L"Failed to define bus type for: " << letter; } CloseHandle(deviceHandle); return BusTypeUsb == busType; } C++ USB query 윈도우 장치 이 글에는 0 개의 댓글이 있습니다. Please enable JavaScript to view the comments powered by Disqus. comments powered by Disqus