How to get the Drive letter
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#{a5dcbf1 0-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.
Re: How to get the Drive letter
You can't do this easily. The best way would be to compare the GUID (eg. "\\?\Volume{GUID}\") with that returned by GetVolumeNameForVolumeMountPoint()
Re: How to get the Drive letter
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
Re: How to get the Drive letter
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
Re: How to get the Drive letter
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.
Re: How to get the Drive letter
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
Re: How to get the Drive letter
You probably need the Win32 SDK
Re: How to get the Drive letter
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
Code:
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;
}
Re: How to get the Drive letter
Dear Experts,
Kindly guide me on my problem
Re: How to get the Drive letter
Dear juicy....
Kindly have look at my problem and please help me up
Re: How to get the Drive letter
I am in the beginner level
really i am looking for some guidence
so sorry to be annoying....