PDA

View Full Version : How to get the Drive letter



newb
8th June 2010, 12:53
Dear All,

I am using Qt with Win32 API.

what i have is SP_DEVICE_INTERFACE_DETAIL_DATA DevicePath

using this Device path i get VID AND PID of the usb device

my device path looks like below

"\?\usb#vid_1a8d&pid_1000#358094020874450#{a5dcbf10-6530-11d2-901f-00c04fb951ed}"

Is there any way to to map DRIVE LETTER to my DEVICE PATH

so please help me to map drive letter to DevicePath

Thanks for any help.

squidge
8th June 2010, 13:26
You can't do this easily. The best way would be to compare the GUID (eg. "\\?\Volume{GUID}\") with that returned by GetVolumeNameForVolumeMountPoint()

newb
8th June 2010, 14:11
Hi friend ...

Thanks for the reply...

Can you please tell me where i can get the GUID as you mentioned.i mean which returns that.

i don find anything with the DevicePath

Thanks for any help

newb
9th June 2010, 11:12
Hi..

To get the volume GUID as you mentioned i tried the code like below

#define BUFFER_SIZE MAX_PATH

WCHAR volume[BUFFER_SIZE];

BOOL bFlag;

bFlag = GetVolumeNameForVolumeMountPoint( pDetData->DevicePath, volume, BUFFER_SIZE );

the bFlag always returns zero it means false.

is there any problem in my code...

please help me up to get the above function work right

squidge
9th June 2010, 12:49
You can't pass a DevicePath to that function, that's why it fails. However, you could pass it to IOCTL_MOUNTMGR_QUERY_POINTS, and that will return a GUID.

newb
9th June 2010, 15:37
Thanks for the reply dude...

when i include #include <Mountmgr.h> to use the IOCTL_MOUNTMGR_QUERY_POINTS

i get the below error

fatal error C1083: Cannot open include file: Mountmgr.h: No such file or directory

How can i solve this error.


Please guide me

squidge
9th June 2010, 16:08
You probably need the Win32 SDK

newb
10th June 2010, 07:42
I have fixed that fatal error C1083: Cannot open include file: Mountmgr.h: No such file or directory by WDK installation

Thanks for the Answer dude ..

I am not able to know how to use the IOCTL_MOUNTMGR_QUERY_POINTS .

I have searched the internet and found some sample code to try with.

but i am not sure whether its correct or not....

can you please let me know how to use the IOCTL_MOUNTMGR_QUERY_POINTS to get the drive letter

Thank you for your time

below is my source coode



HANDLE hUsbDevice = CreateFile( pDetData->DevicePath,
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);

UCHAR Bytes[10000];

PMOUNTMGR_MOUNT_POINTS pMntPoints = (PMOUNTMGR_MOUNT_POINTS) Bytes;

MOUNTMGR_MOUNT_POINT mntPoint, *pmnt;

DWORD bytesReturned;

if (hUsbDevice == INVALID_HANDLE_VALUE)
{
qDebug()<<"CreateFile failed with error: %d\n"<<GetLastError();

}
else
{
qDebug ()<<"VALID DEVICE";

BOOL status = DeviceIoControl( hUsbDevice,
IOCTL_MOUNTMGR_QUERY_POINTS,
&mntPoint,
sizeof(MOUNTMGR_MOUNT_POINT),
pMntPoints,
10000,
&bytesReturned,
NULL);

wprintf(L"\tBOOL VALUE : %d\n", status);

qDebug ()<<pMntPoints->MountPoints;

}

newb
10th June 2010, 09:11
Dear Experts,

Kindly guide me on my problem

newb
10th June 2010, 12:59
Dear juicy....

Kindly have look at my problem and please help me up

newb
10th June 2010, 13:59
I am in the beginner level

really i am looking for some guidence

so sorry to be annoying....