473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Getting the PhysicalDrive for the LogicalDisk!

Hello!

I'm working with some USB Events (arrive and remove) using the
ManagementBaseObject!
It works fine, but i need the relation between the physical drive
(\.\\PHYSICALDRIVE0) and the logical drive ("C:").

Is there any possibility to get the physical drive from logical disk c: or
d:?
thx for help!
michael

Nov 17 '05 #1
2 5211

"Matthias Pfeffer" <kn*****@gmx.net> wrote in message
news:uN*************@TK2MSFTNGP14.phx.gbl...
Hello!

I'm working with some USB Events (arrive and remove) using the
ManagementBaseObject!
It works fine, but i need the relation between the physical drive
(\.\\PHYSICALDRIVE0) and the logical drive ("C:").

Is there any possibility to get the physical drive from logical disk c: or
d:?
thx for help!
michael



You have to walk the associaters chain starting from the logicaldisk over
the associated partition(s)down to the phyiscal disk.

Something like this will do....

using(ManagementObject mo = new ManagementObject(
@"Win32_LogicalDisk='D:'"))
{
foreach (ManagementObject b in mo.GetRelated("Win32_DiskPartition"))
{
foreach (ManagementBaseObject c in b.GetRelated("Win32_Diskdrive"))
Console.WriteLine("{0}", c["Name"]);
}
}

Note that it takes some extra time to scan the DiskDrive chain on system
with floppy drives.

Willy.

Nov 17 '05 #2
hi willy!

thanks for your help!
it works! :o)

greetz

"Willy Denoyette [MVP]" <wi*************@telenet.be> schrieb im Newsbeitrag
news:uP**************@TK2MSFTNGP10.phx.gbl...

"Matthias Pfeffer" <kn*****@gmx.net> wrote in message
news:uN*************@TK2MSFTNGP14.phx.gbl...
Hello!

I'm working with some USB Events (arrive and remove) using the
ManagementBaseObject!
It works fine, but i need the relation between the physical drive
(\.\\PHYSICALDRIVE0) and the logical drive ("C:").

Is there any possibility to get the physical drive from logical disk c: or d:?
thx for help!
michael

You have to walk the associaters chain starting from the logicaldisk over
the associated partition(s)down to the phyiscal disk.

Something like this will do....

using(ManagementObject mo = new ManagementObject(
@"Win32_LogicalDisk='D:'"))
{
foreach (ManagementObject b in mo.GetRelated("Win32_DiskPartition"))
{
foreach (ManagementBaseObject c in

b.GetRelated("Win32_Diskdrive")) Console.WriteLine("{0}", c["Name"]);
}
}

Note that it takes some extra time to scan the DiskDrive chain on system
with floppy drives.

Willy.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
0
by: Frank Rosario | last post by:
Hello all; in need of some assistance. I am currently writing some software for our companies intranet, and I need for it to specifically access other machines on the network's Performance...
0
by: Si | last post by:
I'm writing an HttpModule to intecept web method calls and retrieve custom authentication information from their SOAP headers. I have the httpModules tag in web.config and that appears to be...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
2
by: MSK | last post by:
Hi, Continued to my earlier post regaring "Breakpoints are not getting hit" , I have comeup with more input this time.. Kindly give me some idea. I am a newbie to .NET, recently I installed...
4
by: R.Manikandan | last post by:
Hi In my code, one string variable is subjected to contain more amount of characters. If it cross certain limit, the string content in the varabile is automatically getting truncated and i am...
4
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.