473,320 Members | 1,823 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,320 software developers and data experts.

displaying only 1 WMI object


I have this to search every diskdrive there is on a computer.
But now I want to show/acces only 1 diskdrive for example only the C:\
drive.

SelectQuery query = new SelectQuery( "Select * from Win32_DiskDrive" );

ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

foreach (ManagementObject mo in searcher.Get())

{

this.listBox1.Items.Add(mo["DeviceID"]);

}
Nov 17 '05 #1
3 3526

"D.Bot" <de****@riset.nu> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...

I have this to search every diskdrive there is on a computer.
But now I want to show/acces only 1 diskdrive for example only the C:\
drive.

SelectQuery query = new SelectQuery( "Select * from Win32_DiskDrive" );

ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

foreach (ManagementObject mo in searcher.Get())

{

this.listBox1.Items.Add(mo["DeviceID"]);

}


Change you query into:
Select * from Win32_DiskDrive where DeviceId='c:'

and check the .NET framework documentation for samples and the WMI
documentation for possible query options.

Willy.
Nov 17 '05 #2
I know my SQL so there is not my problem, it's that this "function" is
expacting more results then it gets.
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OQ**************@TK2MSFTNGP09.phx.gbl...

"D.Bot" <de****@riset.nu> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...

I have this to search every diskdrive there is on a computer.
But now I want to show/acces only 1 diskdrive for example only the C:\
drive.

SelectQuery query = new SelectQuery( "Select * from Win32_DiskDrive" );

ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

foreach (ManagementObject mo in searcher.Get())

{

this.listBox1.Items.Add(mo["DeviceID"]);

}


Change you query into:
Select * from Win32_DiskDrive where DeviceId='c:'

and check the .NET framework documentation for samples and the WMI
documentation for possible query options.

Willy.

Nov 17 '05 #3
Ok I see, you are using the Win32_DiskDrive class which denotes a physical
drive, so it's 'DeviceID' property contains the physical device name like:
\\\\.\\PHYSICALDRIVE0. A physical drive has no associated drive letter, as
it can hold one or more partitions that each are logical drives that can
have associated drive letters.
What you are looking for (I guess) is the drive letter, in this case you
should use the Win32_LogicalDisk class.
Starting with the Win32_LogicalDisk you can get at the corresponding
partition by querying for the associators of the Win32_LogicalDisk, one you
have the associated partition (win32_diskpartition) you can get at the
win32_diskdrive by querying for it's associators.

Willy.

"D.Bot" <de****@riset.nu> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
I know my SQL so there is not my problem, it's that this "function" is
expacting more results then it gets.
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OQ**************@TK2MSFTNGP09.phx.gbl...

"D.Bot" <de****@riset.nu> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...

I have this to search every diskdrive there is on a computer.
But now I want to show/acces only 1 diskdrive for example only the C:\
drive.

SelectQuery query = new SelectQuery( "Select * from Win32_DiskDrive" );

ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

foreach (ManagementObject mo in searcher.Get())

{

this.listBox1.Items.Add(mo["DeviceID"]);

}


Change you query into:
Select * from Win32_DiskDrive where DeviceId='c:'

and check the .NET framework documentation for samples and the WMI
documentation for possible query options.

Willy.


Nov 17 '05 #4

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

Similar topics

2
by: Rose | last post by:
Hi all, I'm a newbie to C# and .NET, so please be gentle! My limited background is in VBScript,ASP, and Access dbs. I need to retrieve data from a SQL server db (8.0) to be displayed in a...
1
by: Yoshitha | last post by:
hi I have datalist control in my ASP.NET application the problem here is i have used a textbox with multiline true propertly when i enter data like "fdjsfhjksdhfjsdfhsdjhfsdfhsdjfhsd...
20
by: Peter E. Granger | last post by:
I'm having a strange problem (or at least it seems strange to me) trying to display a MessageBox in a VC++ .NET forms application. If I put the call to MessageBox::Show in the form's .h file, it...
1
by: thf | last post by:
Hi, I wish to know how to display a collection of object which is a property in another object in a data grid in VB.Net. For example, I'm displaying a collection of vendor objects (in ArrayList)...
4
by: Jason Chan | last post by:
How can I get the month and year a calendar control current displaying? My problem is I want to load a list of event to a calendar so that it display difference style if there a event for a day....
0
by: Charles Krug | last post by:
List, I'd like to do the following with Tkinter's Frame() object: 1. Display a collection of pack()-able objects. Easy. Done. I hold the objects in a dictionary, mostly so that the owning...
1
by: Andrew Poulos | last post by:
With "normal" SWF HTML there's an EMBED tag nested within an OBJECT tag. How can I check which tag is actually displaying the SWF? I'm using CSS on them and the style on the OBJECT affects the...
3
by: GeekyChicky79 | last post by:
Hi Everyone, I have the project below where I'm pulling out information from 1 table "Subjects", pulling the Subjects, and SubjectCode. The Subjects are displaying in the Combo Box just fine,...
0
by: Turbot | last post by:
Hello there, I have a .net user control that I am displaying on a web page using the following syntax for my object tag: <object id='objLauncher' name='objLauncher' Style='width:600px; height:...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.