How to get the drive letter with physical address like "\\\\.\\PHYSICALDRIVE0"?
How to get the drive letter with physical address like "\\\\.\\PHYSICALDRIVE0"?
You use the Windows API (eg. WMI). As far as I'm aware, Qt has nothing like this.
Yes I am using window API. How to perform this in order to get the drive letter with the provided 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.
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:
Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. VBOX HARDDISK (\\.\PHYSICALDRIVE0) Disk #0, Partition #0 C: VBOX HARDDISK (\\.\PHYSICALDRIVE1) Disk #1, Partition #0 D:To copy to clipboard, switch view to plain text mode
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:
CString strDrives; char Drives1 [ 200 ]; memset(Drives1,'\0',200); GetLogicalDriveStrings(200, Drives1); int i=0; char st [ 100 ]; CString strDevName; strDevName="\\\\.\\"; while (i<DevNum) { strcpy(st,Drives1+i); strDrives += st; strDevName +=st; i+= strlen(st); i+=3; } strDevName.Delete(6);To copy to clipboard, switch view to plain text mode
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.
Bookmarks