I have tried a lot to enumerate usb flash memories from user
mode in Windows 2000. This really beats me.
Microsofts sample usbview gives a lot of information about
usb controllers, hub and ports, but nothing about drive
letters.
With this sample, I can enumerate root hubs and their ports.
This surely gives me information about _which_ usb devices I
have in the system.
I get GUIDS and "driver key names", but not a single drive
letter.
I have also searched the registry for something that can
reveal which drive letters that has usb flash memories.
(For instance HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices and
its binary registry keys).
I have also searched on all those driver key names, root hub
names etc.
Now I start to think that it would be some way to do this
from a kernel driver.
Of course, thats the final resort.
How would that be done then?
Thanks for your attention
Anders Lindén
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
ma...@storagecraft.com
http://www.storagecraft.com
"Anders Lindén" <nom...@nomail.nomail> wrote in message
news:3fde3e00$1...@puffinus.its.uu.se...
bool identifyusbunits()
{
int i;
DWORD bytesreturned;
HANDLE h;
STORAGE_PROPERTY_QUERY propq;
char buff[16];
char outputbuff[1024];
DWORD num=GetLogicalDrives();
DWORD bustype;
for (i=0; i<32; i++)
{
sprintf(buff,"\\\\.\\%c:",i+'A');
propq.PropertyId=StorageDeviceProperty;
propq.QueryType=PropertyStandardQuery;
if
((h=CreateFile(buff,0,0,NULL,OPEN_EXISTING,0,NULL))!=INVALID
_HANDLE_VALUE)
{
if
(DeviceIoControl(h,IOCTL_STORAGE_QUERY_PROPERTY,&propq,sizeo
f(propq),outputbuff,1024,& bytesreturned,NULL))
{
STORAGE_DESCRIPTOR_HEADER
*hdr=(STORAGE_DESCRIPTOR_HEADER *)outputbuff;
STORAGE_DEVICE_DESCRIPTOR
*desc=(STORAGE_DEVICE_DESCRIPTOR *)(outputbuff+sizeof
(STORAGE_DESCRIPTOR_HEADER));
printf("%s: %d\n",buff,desc->BusType);
}
CloseHandle(h);
}
}
return true;
}
I got a very strange result:
\\.\B:: 16809984
\\.\C:: 0
\\.\D:: 0
\\.\E:: 0
\\.\F:: 0
\\.\G:: 0
\\.\H:: 0
\\.\I:: 16809984
\\.\J:: 16809984
\\.\Z:: 0
I and J is the ones that has USB devices, and the number
should be 7, I suppose.
Did I do something terribly wrong in my code?
"Maxim S. Shatskih" <ma...@storagecraft.com> wrote in
message news:brliqo$u72$1...@gavrilo.mtu.ru...
/Anders
"Anders Lindén" <nom...@nomail.nomail> wrote in message
news:3fdf3185$1...@puffinus.its.uu.se...