galapogos
November 21st, 2007, 05:11 AM
Hi,
I'm wondering how I can get a drive letter from a physical drive name such as "\\.\PhysicalDrive2"?
I'm wondering how I can get a drive letter from a physical drive name such as "\\.\PhysicalDrive2"?
|
Click to See Complete Forum and Search --> : How to get logical drive letter from physical drive? galapogos November 21st, 2007, 05:11 AM Hi, I'm wondering how I can get a drive letter from a physical drive name such as "\\.\PhysicalDrive2"? ashukasama November 21st, 2007, 06:55 AM have a look on QueryDosDevice function also good article http://blog.voidnish.com/?p=72 galapogos November 21st, 2007, 07:39 AM Thanks. The article describes how to get the drive letter from a device path, such as "\Device\HarddiskVolume1" or "\Device\CdRom0". What I have is the "\\.\PhysicalDrive1" or "\\.\CdRom0". Is that actually the same, as in the numbers map exactly? ashukasama November 21st, 2007, 08:30 AM in c# very simple way using (ManagementClass devs = new ManagementClass(@"Win32_Diskdrive")) { ManagementObjectCollection moc = devs.GetInstances(); foreach (ManagementObject mo in moc) { Console.WriteLine(mo["DeviceId"]); foreach (ManagementObject b in mo.GetRelated("Win32_DiskPartition")) { Console.WriteLine("{0}", b["Name"]); foreach (ManagementBaseObject c in b.GetRelated("Win32_LogicalDisk")) Console.WriteLine("{0}", c["Name"]); } } } in VC++ One class is there Win32_LogicalDiskToPartition for this. you can have a look on that. galapogos November 21st, 2007, 08:50 AM I'm actually writing this is straight C. ashukasama November 21st, 2007, 09:00 AM sorry no idea , :cry: i know either WMI services to get detail or c# way galapogos November 21st, 2007, 10:14 AM Thanks for the help anyway...anyone else? Could really use some help. Edit: After some googling and trying out on my own, it would appear that \Device\\HarddiskX is the same as PhysicalDriveX. The code works! :) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |