Results 1 to 7 of 7

Thread: How to get the drive letter using Physical address??

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to get the drive letter using Physical address??

    How to get the drive letter with physical address like "\\\\.\\PHYSICALDRIVE0"?

  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 using Physical address??

    You use the Windows API (eg. WMI). As far as I'm aware, Qt has nothing like this.

  3. #3
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to get the drive letter using Physical address??

    Yes I am using window API. How to perform this in order to get the drive letter with the provided physical address?

  4. #4
    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 using Physical address??

    Like I said, one way would be to use WMI.

    How to use WMI is beyond the scope of this forum. A better forum would be one which specialises in the Windows API.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to get the drive letter using Physical address??

    Your question is not trivial. A physical drive can contain zero, one, or more Windows volumes or, indeed, only part of one or more Windows volumes. A Windows volume may exist on the physical drive but have no drive letter.

    If you don't know how the Windows API, particularly WMI, then it is best you start by reading Microsoft's documentation. Then, if you still cannot work it out, ask your question somewhere there is likely to be some expertise in Windows API intricacies.

    Here are a few pages from a straightforward Google search:
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    http://www.activexperts.com/activmon...lDiskDrive.htm

    The second one contains a WMI script that outputs this on one on my test machines:
    Qt Code:
    1. Microsoft (R) Windows Script Host Version 5.7
    2. Copyright (C) Microsoft Corporation. All rights reserved.
    3.  
    4. VBOX HARDDISK (\\.\PHYSICALDRIVE0)
    5. Disk #0, Partition #0
    6. C:
    7. VBOX HARDDISK (\\.\PHYSICALDRIVE1)
    8. Disk #1, Partition #0
    9. D:
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to get the drive letter using Physical address??

    I have used this in VC application. But am getting the c: drive only in strDevName .If a particular drive is chosen. List of all drives will be in strDrives. I want to get the drive letter for the corresponding drive number?? please help me..

    Qt Code:
    1. CString strDrives;
    2. char Drives1 [ 200 ];
    3. memset(Drives1,'\0',200);
    4. GetLogicalDriveStrings(200, Drives1);
    5. int i=0;
    6. char st [ 100 ];
    7. CString strDevName;
    8. strDevName="\\\\.\\";
    9.  
    10. while (i<DevNum)
    11. {
    12. strcpy(st,Drives1+i);
    13. strDrives += st;
    14. strDevName +=st;
    15. i+= strlen(st);
    16. i+=3;
    17. }
    18. strDevName.Delete(6);
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to get the drive letter using Physical address??

    Read the thread again. You are asking a Windows API specific question in a Qt forum. Your example code is Microsoft specific classes and API calls. Asking the question again and again will not change the fact that this is the wrong place for your question.

Similar Threads

  1. Replies: 5
    Last Post: 23rd January 2011, 11:27
  2. How to get the Drive letter
    By newb in forum Qt Programming
    Replies: 10
    Last Post: 10th June 2010, 13:59
  3. Shourtcut for letter
    By swrer in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2010, 10:29
  4. OS/X how to get physical display handle
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2009, 19:51
  5. How to highlight a letter in menu
    By npc in forum Newbie
    Replies: 2
    Last Post: 14th March 2006, 12: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.