Click to See Complete Forum and Search --> : Physical Drive from Logical Drive
CJ1
January 9th, 2004, 05:40 PM
Here is one for the for the bit junkies:
I need to get the physical drive name (under Windows NT/2000) from the logical drive letter.
For example I have been given logical drive "R:" and I need to map it to the Physical drive name "PhysicalDrive2" which I can use in a call to CreateFile() (read-only mode).
Calling QueryDosDevice() does NOT return a device name that CreateFile() will accept.
I haven't found any other Win32 call that even comes close.
Any thoughts or suggestions?
j0nas
January 9th, 2004, 07:12 PM
First, I don't know how to map a logical drive to a physical... But, if you just want to open a drive with CreateFile, you can specify "\\\\.\\C:" as device name to CreateFile(). Then you don't need to map it. Don't know if that also works on 9x/Me.
Hope it helped.
CJ1
January 9th, 2004, 07:20 PM
No, I need to go one level deeper. What you suggest only gets me to the LogicalDrive (the DOS Volume).
What I need is access to the physical drive, where you find the Master Boot Record and Partition Table.
Chris...
P.S. No, that doesn't work on Win95/98, you need to CreateFile() with VWIN32 and then issue Inetrrupt 25 calls using DeviceIoControl().
Hope that clears it up.
nicepat
April 19th, 2004, 12:55 PM
Yes, as your advice, I used '\\\\.\\C:' value for the first argument in the QueryDosDevice(). It returns 161, invalid path name.
MyDevice = "\\\\.\\C:";
if (QueryDosDevice(MyDevice, LinkName, sizeof(LinkName)) == 0) {
..... print error
}
} else {
bCreatedDevice = FALSE;
printf("QueryDosDevice successfully opens the existing device file.\n");
}
This is the peice of the code in my hand. Please make me correct....
CJ1
April 19th, 2004, 05:17 PM
If memory serves me, QueryDosDevice() takes the DOS drive name, "C:" in this case.
To open the drive, call CreateFile() with "\\\\.\\C:"
nicepat
April 20th, 2004, 03:41 PM
yes it is true. you can use "\\\\.\\C:" or your may use the resturned parameter from QueryDosDevice() like 'LinkName' from my sample. I checked this parameter has the equal value.
personally, I prefer this value because of more system-reliable.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.