Is Usb Drive () ? DeviceIoControl, IOCTL_STORAGE_QUERY_PROPERTY
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的更多相关文章
- [OrangePi] Booting from USB drive
You can also boot from USB drive partition. The file named cmdline.txt must exist on BOOT (fat) part ...
- 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 ...
- 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 ...
- 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 ...
- How to match between physical usb device and its drive letter?
struct tagDrives { WCHAR letter; WCHAR volume[ BUFFER_SIZE ]; } g_drives[ ]; // WCHAR GetUSBDrive( ) ...
- Install Slax on USB device (Slax U 盘安装)
Slax is a modern, portable, small and fast Linux operating system with a modular approach and outsta ...
- 用UNetbootin来安装USB LINUX,好像比ULTRA ISO省事
UNetbootin can create a bootable Live USB drive, or it can make a "frugal install" on your ...
- 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 ...
- 设备管理 USB ID
发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...
随机推荐
- vue项目下使用iview总结
iview在IE浏览器下有问题,打开页面是空白
- python并行计算(持续更新)
工作中需要对tensorflow 的一个predict结果加速,利用python中的线程池 def getPPLs(tester,datas): for line in datas: tester(l ...
- No.18 selenium学习之路之批量执行测试用例
diascover方法,加载所有测试用例 1.discover方法里面有三个参数: -case_dir:测试用例的目录 -pattern:这个是匹配脚本名称的规则,test*.py意思是匹配test开 ...
- windows系统 安装MongoDB
1.下载 官网下载地址:https://www.mongodb.com/download-center#community 2.配置MongoDB a.在e:\MongoDB(可随意起)下面建一个da ...
- Python SGMLParser 的1个BUG??
首先说一下,我用的是python 2.7,刚好在学Python,今天想去爬点图片当壁纸,但是当我用 SGMLParser 做 <img> 标签解析的时候,发现我想要的那部分根本没获取到,我 ...
- Python之Selenium的爬虫用法
Selenium 2,又名 WebDriver,它的主要新功能是集成了 Selenium 1.0 以及 WebDriver(WebDriver 曾经是 Selenium 的竞争对手).也就是说 Sel ...
- 使用EasyWechat快速开发微信公众号支付
前期准备: 申请微信支付后, 会收到2个参数, 商户id,和商户key.注意,这2个参数,不要和微信的参数混淆.微信参数: appid, appkey, token支付参数: merchant_id( ...
- day6 hashlib模块
hashlib模块 用于加密相关的文件操作,3.X离代替了md5模块和sha模块,主要提供SHA1,SHA224,SHA256,SHA384,SHA512,MD5算法 __always_sup ...
- nullptr
以前都是用0来表示空指针的,但由于0可以被隐式类型转换为整形,这就会存在一些问题.关键字nullptr是std::nullptr_t类型的值,用来指代空指针.nullptr和任何指针类型以及类成员指针 ...
- LeetCode 80. 删除排序数组中的重复项 II
LeetCode 80. 删除排序数组中的重复项 II