Results 1 to 11 of 11

Thread: How to get the Drive letter

  1. #1
    Join Date
    Apr 2010
    Posts
    48
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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()

  3. #3
    Join Date
    Apr 2010
    Posts
    48
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  4. #4
    Join Date
    Apr 2010
    Posts
    48
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  6. #6
    Join Date
    Apr 2010
    Posts
    48
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to get the Drive letter

    You probably need the Win32 SDK

  8. The following user says thank you to squidge for this useful post:

    newb (10th June 2010)

  9. #8
    Join Date
    Apr 2010
    Posts
    48
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

    Qt Code:
    1. HANDLE hUsbDevice = CreateFile( pDetData->DevicePath,
    2. GENERIC_READ | GENERIC_WRITE,
    3. 0, NULL, OPEN_EXISTING, 0, NULL);
    4.  
    5. UCHAR Bytes[10000];
    6.  
    7. PMOUNTMGR_MOUNT_POINTS pMntPoints = (PMOUNTMGR_MOUNT_POINTS) Bytes;
    8.  
    9. MOUNTMGR_MOUNT_POINT mntPoint, *pmnt;
    10.  
    11. DWORD bytesReturned;
    12.  
    13. if (hUsbDevice == INVALID_HANDLE_VALUE)
    14. {
    15. qDebug()<<"CreateFile failed with error: %d\n"<<GetLastError();
    16.  
    17. }
    18. else
    19. {
    20. qDebug ()<<"VALID DEVICE";
    21.  
    22. BOOL status = DeviceIoControl( hUsbDevice,
    23. IOCTL_MOUNTMGR_QUERY_POINTS,
    24. &mntPoint,
    25. sizeof(MOUNTMGR_MOUNT_POINT),
    26. pMntPoints,
    27. 10000,
    28. &bytesReturned,
    29. NULL);
    30.  
    31. wprintf(L"\tBOOL VALUE : %d\n", status);
    32.  
    33. qDebug ()<<pMntPoints->MountPoints;
    34.  
    35. }
    To copy to clipboard, switch view to plain text mode 

  10. #9
    Join Date
    Apr 2010
    Posts
    48
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to get the Drive letter

    Dear Experts,

    Kindly guide me on my problem

  11. #10
    Join Date
    Apr 2010
    Posts
    48
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to get the Drive letter

    Dear juicy....

    Kindly have look at my problem and please help me up

  12. #11
    Join Date
    Apr 2010
    Posts
    48
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default 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....

Similar Threads

  1. Shourtcut for letter
    By swrer in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2010, 11:29
  2. How to recognize a letter from a Qstring?
    By luffy27 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2007, 20:22
  3. problem of how to get drive
    By jyoti in forum General Programming
    Replies: 6
    Last Post: 30th November 2006, 15:18
  4. adjust Letter Spacing
    By niko in forum Newbie
    Replies: 3
    Last Post: 16th August 2006, 11:05
  5. How to highlight a letter in menu
    By npc in forum Newbie
    Replies: 2
    Last Post: 14th March 2006, 13:18

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.