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 ...
随机推荐
- python网络编程-多进程multiprocessing
一:mutilprocess简介 多线程类似于同时执行多个不同程序,多线程运行有如下优点: 使用线程可以把占据长时间的程序中的任务放到后台去处理. 用户界面可以更加吸引人,这样比如用户点击了一个按钮去 ...
- kafka集群及监控部署
1. kafka的定义 kafka是一个分布式消息系统,由linkedin使用scala编写,用作LinkedIn的活动流(Activity Stream)和运营数据处理管道(Pipeline)的基础 ...
- qlserver排序规则在全角与半角处理中的应用
--1.查询区分全角与半角字符--测试数据DECLARE @t TABLE(col varchar(10))INSERT @t SELECT 'aa'UNION ALL SELECT 'Aa'UNIO ...
- 20165203 实验三 敏捷开发与XP实践
20165203 实验三 敏捷开发与XP实践 任务一: 1.实验要求 实验三 敏捷开发与XP实践 (http://www.cnblogs.com/rocedu/p/4795776.html), Ecl ...
- C#socket编程序(一)
在讲socket编程之前,我们先看一下最常用的一些类和方法,相信这些能让你事半功倍. 一.IP地址操作类 1.IPaddress类 a.在该类中有一个 parse()方法,能够把点分十进制IP地址 转 ...
- 21 包含min函数的栈
定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数. C++: class Solution { private: stack<int> dataStack ; stac ...
- Adapter.notifyDataSetChanged()源码分析以及与ListView.setAdapter的区别
一直很好奇,notifyDataSetChanged究竟是重绘了整个ListView还是只重绘了被修改的那些Item,它与重新设置适配器即调用setAdapter的区别在哪里?所以特地追踪了一下源码, ...
- jquery图片延迟加载方案解决图片太多加载缓慢问题
当在做一个图片展示站的时候,一个页面加载的图片过多会,如果服务器的带宽跟不上,明显会感觉到页面很卡,严重的浏览器也会崩溃,所以我推荐采用即看即所得的模式,当滚动到下一屏时才进行加载图片. 注意:即便如 ...
- python日期格式转换小记
utc格林时间==>东八区北京时间 原始日期格式: utctime = ‘2016-07-26 10:08:29’ localtime = (datetime.datetime.fromtime ...
- pct_free
SQL> select table_name,pct_free,pct_used from user_tables; TABLE_NAME PCT_FREE PCT_USED---------- ...