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.