http://banderlogi.blogspot.com/2011/06/enum-drive-letters-attached-for-usb.html

typedef enum _STORAGE_BUS_TYPE {
BusTypeUnknown = 0x00,
BusTypeScsi = 0x01,
BusTypeAtapi = 0x02,
BusTypeAta = 0x03,
BusType1394 = 0x04,
BusTypeSsa = 0x05,
BusTypeFibre = 0x06,
BusTypeUsb = 0x07,
BusTypeRAID = 0x08,
BusTypeiSCSI = 0x09,
BusTypeSas = 0x0A,
BusTypeSata = 0x0B,
BusTypeMaxReserved = 0x7F
} STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
typedef struct _STORAGE_DEVICE_DESCRIPTOR {
DWORD Version;
DWORD Size;
BYTE DeviceType;
BYTE DeviceTypeModifier;
BOOLEAN RemovableMedia;
BOOLEAN CommandQueueing;
DWORD VendorIdOffset;
DWORD ProductIdOffset;
DWORD ProductRevisionOffset;
DWORD SerialNumberOffset;
STORAGE_BUS_TYPE BusType;
DWORD RawPropertiesLength;
BYTE RawDeviceProperties[];
} STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
bool IsUsbDevice( wchar_t letter )
{
wchar_t volumeAccessPath[ ] = L"\\\\.\\X:";
volumeAccessPath[ ] = letter; HANDLE deviceHandle = CreateFileW( volumeAccessPath, , // no access to the drive
FILE_SHARE_READ | // share mode
FILE_SHARE_WRITE, NULL, // default security attributes
OPEN_EXISTING, // disposition
, // file attributes
NULL ); // do not copy file attributes // setup query
STORAGE_PROPERTY_QUERY query;
memset( &query, , 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;
}

Is Usb Drive () ? DeviceIoControl, IOCTL_STORAGE_QUERY_PROPERTY的更多相关文章

  1. [OrangePi] Booting from USB drive

    You can also boot from USB drive partition. The file named cmdline.txt must exist on BOOT (fat) part ...

  2. Does anyone successfully use USB drive in Windows7 guest?

    Hi, Does anyone successfully use USB drive in Windows7 guest? If I pass a USB drive to Windows7 gues ...

  3. Removing bad blocks from the USB drive with fsck

    An easy way to repair a flash drive, or any drive really, is to use the fsck tool. This tool is grea ...

  4. How to Mount a USB Drive in Ubuntu

    Read more : http://www.ehow.com/how_6762235_mount-usb-drive-ubuntu.html Most USB drives will automou ...

  5. How to match between physical usb device and its drive letter?

    struct tagDrives { WCHAR letter; WCHAR volume[ BUFFER_SIZE ]; } g_drives[ ]; // WCHAR GetUSBDrive( ) ...

  6. Install Slax on USB device (Slax U 盘安装)

    Slax is a modern, portable, small and fast Linux operating system with a modular approach and outsta ...

  7. 用UNetbootin来安装USB LINUX,好像比ULTRA ISO省事

    UNetbootin can create a bootable Live USB drive, or it can make a "frugal install" on your ...

  8. fuel iso光盘刻录机usb Driver 烧录

    ISO image to a DVD or burn the IMG file to a USB drive For a bare-metal installation ipmitool, HP iL ...

  9. 设备管理 USB ID

    发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...

随机推荐

  1. centos7的防火墙(firewalld)

    Centos7中默认将原来的防火墙iptables升级为了firewalld,firewalld跟iptables比起来至少有两大好处: 1.firewalld可以动态修改单条规则,而不需要像ipta ...

  2. 添加自签发的 SSL 证书为受信任的根证书

    原文:http://cnzhx.net/blog/self-signed-certificate-as-trusted-root-ca-in-windows/ 添加自签发的 SSL 证书为受信任的根证 ...

  3. No.18 selenium学习之路之批量执行测试用例

    diascover方法,加载所有测试用例 1.discover方法里面有三个参数: -case_dir:测试用例的目录 -pattern:这个是匹配脚本名称的规则,test*.py意思是匹配test开 ...

  4. hdu 4349 求C(n,0),C(n,1),C(n,2)...C(n,n).当中有多少个奇数 (Lucas定理推广)

    Lucas定理:把n写成p进制a[n]a[n-1]a[n-2]...a[0],把m写成p进制b[n]b[n-1]b[n-2]...b[0],则C(n,m)与C(a[n],b[n])*C(a[n-1], ...

  5. 《精通Python设计模式》学习结构型之代理模式

    这种模式,总会让人想到SRPING中的AOP, 不同语言有不同的实现方式吧. class SensitiveInfo: def __init__(self): self.users = ['nick' ...

  6. bzoj 2752

    2752 思路: 线段树: 代码: #include <cstdio> #include <cstring> #include <iostream> #includ ...

  7. Python全栈开发之14、Javascript

    一.简介 前面我们学习了html和css,但是我们写的网页不能动起来,如果我们需要网页出现各种效果,那么我们就要学习一门新的语言了,那就是JavaScript,JavaScript是世界上最流行的脚本 ...

  8. UVa210 Concurrency Simulator (ACM/ICPC World Finals 1991) 双端队列

    Programs executed concurrently on a uniprocessor system appear to be executed at the same time, but ...

  9. Java拾遗补缺

    JDK9的lib目录下已经不再包含dt.jar和tool.jar.

  10. hdu1312 Red and Black

    I - Red and Black Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...