473,703 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WMI Hard drive Physical address and drive letter

How can I use WMI or a WqlObjectQuery to find the hard drive letter of the
physical drive location index.

For example the following code will give me the physical drive location:
StringCollectio n propNames = new StringCollectio n();
ManagementClass driveClass = new ManagementClass ("Win32_DiskDri ve");
PropertyDataCol lection props = driveClass.Prop erties;
foreach (PropertyData driveProperty in props)
{
propNames.Add(d riveProperty.Na me);
}
ManagementObjec tCollection drives = driveClass.GetI nstances();
foreach (ManagementObje ct drv in drives)
{
string id = "Index";
this.listBox1.I tems.Add(" ******** Drive( " + drv[id].ToString() + " )
Location ************");
}

And, the follwoing code will give me the drive letter:

SelectQuery query = new SelectQuery( "select name, FreeSpace, SystemName
from win32_logicaldi sk where drivetype=3" );
ManagementObjec tSearcher searcher = new ManagementObjec tSearcher(query );
foreach (ManagementObje ct mo in searcher.Get())
{
this.listBox1.I tems.Add( "Drive letter is: " + mo["name"] );
}

How can I do a query using the drive location and get the drive letter
assigned to it?



Nov 17 '05 #1
0 2497

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

Similar topics

0
1530
by: robswin | last post by:
I'm working on a storage subsystem test solution and am looking for a way to manage disks as they appear to windows (physical disks, showing up as WMI class entries of type Win32_DiskDrive). I need to be able to: create partitions on the disks, format the disks, and present them to Windows as a logical disk (drive letter), unpresent them and delete partitions. Basically, everything that the Disk Management tool in the Computer Management...
1
2387
by: Daniel | last post by:
when writing out a file from .net, when is the file created? after the bytes are all written to the hard drive or before the bytes are written to the hard drive?
2
3599
by: Massimiliano Campagnoli | last post by:
Good morning, Database PRODUCTION was created on a system mamanged tablespace on drive c:\ Now drive c:\ is running out of space and I need to move PRODUCTION to the larger drive d:\ on the same machine. PRODUCTION is currently accessed by 50 clients running many applications and by some REXX scripts running on the same server machine on a timely basis. I do not want to modify in any way clients configuration, applications,
7
24159
by: jimdscudder | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location: StringCollection propNames = new StringCollection(); ManagementClass driveClass = new ManagementClass("Win32_DiskDrive"); PropertyDataCollection props = driveClass.Properties; foreach (PropertyData driveProperty in props) { propNames.Add(driveProperty.Name);
3
2167
by: (PeteCresswell) | last post by:
I'm writing a little app in which people open up text files that get massaged and then used to update other files. They us Common File Dialog to navigate to the input files. I'd like to record which files were chosen, but at the \\ServerName\ShareName\DirectoryName level. Seems like the Common File Dialog will always(?) return a path that starts with a drive letter instead of the full ServerName/ShareName/DirectoryName info.
4
14483
by: Zeeshan | last post by:
hi, i want to get the hard drive number for example if if have drive letter C it should tell me Disk number as 1 and suppose if i have another hard disk attach to my system having letter J, the by giving J it should give me disk number 2. Any kind of help will be fuly appreciated Regards, Zeeshan
2
8198
by: Kavitha | last post by:
Hi , Can any one tel me how to create a virtual drive in C#( similar to Gmail Virtual drive).Also tell me what interfaces could be used to create the same. Thanks in Advance Kavitha
2
7440
by: unknown; | last post by:
hi, i want to write an application who can acces a disk/partition in windows xp. I know how to do that if the disk/partition has a drive letter. But in this case the disk has no driveletter and is in that case for normal users invisible in windows xp. i've searched the internet but i don't know where to look and i don;t know how to describe my problem.
4
3467
by: Jim Carlock | last post by:
function CreateMyDataBaseFile($FQFN, $UID, $PW) { $db = "sqlite:" . $FQFN; $sql = "CREATE TABLE Customers(name1 TEXT, name2 TEXT);"; $dbh = new PDO($db, $UID, $PW); $dbh->exec($sql); $dbh = null; } This works as long as a drive letter is not FQFN. For instance,
0
8749
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9243
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7853
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.