From: FrankNatoli on 7 Feb 2010 07:46 Need to map a USB drive to its Windows physical drive number and logical driver letter. Have software that does so successfully under Windows 7 but not WinXP and need to get it running on WinXP. First call SetupDiGetClassDevs for GUID_DEVINTERFACE_USB_DEVICE, then iterate with SetupDiGetDeviceRegistryProperty for SPDRP_HARDWAREID. When I find an SPDRP_HARDWAREID that matches my USB device vendor and product IDs, I can use the SP_DEVINFO_DATA to extract DevInst. Then map the abovementioned DevInst via CM_Get_Child to a child instance. Then call SetupDiGetClassDevs for GUID_DEVINTERFACE_DISK, then iterate with SetupDiEnumDeviceInfo for a SP_DEVINFO_DATA DevInst that matches the child instance. Then again call SetupDiGetClassDevs for GUID_DEVINTERFACE_DISK, then iterate with SetupDiEnumDeviceInterfaces filtering by the SP_DEVINFO_DATA returned in the previous step. With each iteration, call SetupDiGetDeviceInterfaceDetail, which will return a detail string that can be used with CreateFile. Call CreateFile with detail string. Call DeviceIoControl IOCTL_STORAGE_GET_DEVICE_NUMBER. Extract DeviceNumber for physical drive number. The above works for Windows 7. The physical drive number returned by IOCTL_STORAGE_GET_DEVICE_NUMBER is 1, which is correct for the system being used. But under WinXP, although the CreateFile detail string clearly is the USB device [can see manufacturer name buried in the string], IOCTL_STORAGE_GET_DEVICE_NUMBER physical drive number is 0, which should be the C: drive and not the USB E: drive. What is wrong with the above? Or what is the correct steps to establish the association between USB device and the storage device the USB becomes? Please note that all Win32 calls are successful. The mention of zero returns above are for the data in the structures, not the function return code. Thanks.
From: Uwe Sieber on 10 Feb 2010 03:04 Never had a problem with that. Does my tool show the device numbers? http://www.uwe-sieber.de/files/listdisks.zip (console app for testing, no params) Uwe FrankNatoli wrote: > Need to map a USB drive to its Windows physical drive number and > logical driver letter. Have software that does so successfully under > Windows 7 but not WinXP and need to get it running on WinXP. > > First call SetupDiGetClassDevs for GUID_DEVINTERFACE_USB_DEVICE, then > iterate with SetupDiGetDeviceRegistryProperty for SPDRP_HARDWAREID. > When I find an SPDRP_HARDWAREID that matches my USB device vendor and > product IDs, I can use the SP_DEVINFO_DATA to extract DevInst. > > Then map the abovementioned DevInst via CM_Get_Child to a child > instance. > > Then call SetupDiGetClassDevs for GUID_DEVINTERFACE_DISK, then iterate > with SetupDiEnumDeviceInfo for a SP_DEVINFO_DATA DevInst that matches > the child instance. > > Then again call SetupDiGetClassDevs for GUID_DEVINTERFACE_DISK, then > iterate with SetupDiEnumDeviceInterfaces filtering by the > SP_DEVINFO_DATA returned in the previous step. With each iteration, > call SetupDiGetDeviceInterfaceDetail, which will return a detail > string that can be used with CreateFile. > > Call CreateFile with detail string. Call DeviceIoControl > IOCTL_STORAGE_GET_DEVICE_NUMBER. Extract DeviceNumber for physical > drive number. > > The above works for Windows 7. The physical drive number returned by > IOCTL_STORAGE_GET_DEVICE_NUMBER is 1, which is correct for the system > being used. But under WinXP, although the CreateFile detail string > clearly is the USB device [can see manufacturer name buried in the > string], IOCTL_STORAGE_GET_DEVICE_NUMBER physical drive number is 0, > which should be the C: drive and not the USB E: drive. > > What is wrong with the above? Or what is the correct steps to > establish the association between USB device and the storage device > the USB becomes? > > Please note that all Win32 calls are successful. The mention of zero > returns above are for the data in the structures, not the function > return code. > > Thanks.
|
Pages: 1 Prev: latest nvidia drivers knock out Aero in win 7 Next: Getting started with a wlan driver |