Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

list of all the installed devices

7,485 views
Skip to first unread message

John Smith

unread,
Apr 9, 2003, 12:23:00 PM4/9/03
to
i want to get the list of the installed devices on a machine. I only need
the pci, ide and scsi (maybe usb) devices installed on the box. I was looked
thru WMI and Win32_SystemDriver but was unable to find a way to filter the
results for just those things...

can someone point me right direction?? maybe i am missing something in
Win32_* can will do what i am looking for...

-thankz


Nicholas Paldino [.NET/C# MVP]

unread,
Apr 9, 2003, 12:31:07 PM4/9/03
to
John,

You will want to check out the following WMI classes:

Win32_USBControllerDevice
Win32_SCSIControllerDevice
Win32_IDEControllerDevice

I can't find anything for the PCI slots, but I am sure there is
something in there.

The classes listed above should give you the items that are connected to
these controllers.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nicholas...@exisconsulting.com

"John Smith" <som...@microsoft.com> wrote in message
news:u62YxSr$CHA....@TK2MSFTNGP10.phx.gbl...

John Smith

unread,
Apr 9, 2003, 2:11:04 PM4/9/03
to
thankz for the reply Nicholas...

ok this is what i am trying....
[Code lang="C#"]
ObjectQuery oq =
new System.Management.ObjectQuery("SELECT * FROM
Win32_IDEControllerDevice");
ManagementObjectSearcher query =
new ManagementObjectSearcher(oq);
ManagementObjectCollection queryCollection = query.Get();

foreach ( ManagementObject mo in queryCollection)
{
Console.WriteLine("Antecedent : "+mo["Antecedent"]);
Console.WriteLine("Dependant : "+mo["Dependent"]);
}
[/Code]

now the "Dependent" is a CIM_LogicalDevice reference, how do i get the value
for its(CIM_LogicalDevice) properities like "Caption" and all the other
good stuff ...

[Output]
Antecedent :
\\JAGERMEISTER\root\cimv2:Win32_IDEController.DeviceID="PCI\\VEN_8086&DEV_24
CB&SUBSYS_01471028&REV_02\\3&13C0B0C5&0&F9"
Dependant :
\\JAGERMEISTER\root\cimv2:Win32_PnPEntity.DeviceID="PCIIDE\\IDECHANNEL\\4&1D
C52276&0&0"
Antecedent :
\\JAGERMEISTER\root\cimv2:Win32_IDEController.DeviceID="PCI\\VEN_8086&DEV_24
CB&SUBSYS_01471028&REV_02\\3&13C0B0C5&0&F9"
Dependant :
\\JAGERMEISTER\root\cimv2:Win32_PnPEntity.DeviceID="PCIIDE\\IDECHANNEL\\4&1D
C52276&0&1"
Antecedent :
\\JAGERMEISTER\root\cimv2:Win32_IDEController.DeviceID="PCIIDE\\IDECHANNEL\\
4&1DC52276&0&0"
Dependant :
\\JAGERMEISTER\root\cimv2:Win32_PnPEntity.DeviceID="IDE\\DISKMAXTOR_6E030L0_
_________________________NAR61590\\31454633435A4551202020202020202020202020"
Antecedent :
\\JAGERMEISTER\root\cimv2:Win32_IDEController.DeviceID="PCIIDE\\IDECHANNEL\\
4&1DC52276&0&1"
Dependant :
\\JAGERMEISTER\root\cimv2:Win32_PnPEntity.DeviceID="IDE\\CDROMSAMSUNG_CD-ROM
_SC-148C__________________B105____\\5&1202A50F&0&0.0.0"
[/Output]

"Nicholas Paldino [.NET/C# MVP]" <nicholas...@exisconsulting.com> wrote
in message news:OagBXXr$CHA....@TK2MSFTNGP12.phx.gbl...

Nicholas Paldino [.NET/C# MVP]

unread,
Apr 9, 2003, 2:36:27 PM4/9/03
to
John,

You should be able to access it like any other property, like this:

foreach ( ManagementObject mo in queryCollection)
{
Console.WriteLine("Antecedent : "+mo["Antecedent"]);
Console.WriteLine("Dependant : "+mo["Dependent"]);

Console.WriteLine("Caption : "+mo["Caption"]);
}

It should work.


--
- Nicholas Paldino [.NET/C# MVP]
- nicholas...@exisconsulting.com

"John Smith" <som...@microsoft.com> wrote in message

news:uC5wKPs$CHA....@TK2MSFTNGP10.phx.gbl...

John Smith

unread,
Apr 9, 2003, 2:45:25 PM4/9/03
to
nope...

Unhandled Exception: System.Management.ManagementException: Not found

at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode)

at System.Management.PropertyData.RefreshPropertyInfo()

at System.Management.PropertyData..ctor(ManagementBaseObject parent, String
propName)

at System.Management.PropertyDataCollection.get_Item(String propertyName)

at System.Management.ManagementBaseObject.GetPropertyValue(String
propertyName)

at System.Management.ManagementBaseObject.get_Item(String propertyName)

at SampleWinApp.Form1.devices() in c:\documents and settings\alok khanna\my
documents\visual studio projects\samplewinapp\form1.cs:line 54

at SampleWinApp.Form1..ctor() in c:\documents and settings\alok khanna\my
documents\visual studio projects\samplewinapp\form1.cs:line 31

at SampleWinApp.Form1.Main() in c:\documents and settings\alok khanna\my
documents\visual studio projects\samplewinapp\form1.cs:line 120The program
'[2884] SampleWinApp.exe' has exited with code 0 (0x0).

"Nicholas Paldino [.NET/C# MVP]" <nicholas...@exisconsulting.com> wrote

in message news:ukcaZds$CHA....@TK2MSFTNGP12.phx.gbl...

Nicholas Paldino [.NET/C# MVP]

unread,
Apr 9, 2003, 2:50:38 PM4/9/03
to
John,

I checked the Win32_IDEControllerDevice WMI class, and there is no
Caption property on it, or anywhere on the heiarchy tree.


--
- Nicholas Paldino [.NET/C# MVP]
- nicholas...@exisconsulting.com

"John Smith" <som...@microsoft.com> wrote in message

news:uJvdWis$CHA....@TK2MSFTNGP11.phx.gbl...

John Smith

unread,
Apr 9, 2003, 2:59:22 PM4/9/03
to
i know that thats y i said..

>now the "Dependent" is a CIM_LogicalDevice reference, how do i get the
value for its(CIM_LogicalDevice) properities like "Caption"

the caption property is for the CIM_LogicalDevice (link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
cim_logicaldevice.asp )... and since the "dependent" property is a reference
to that class, there is should be a way to get the caption property for the
dependent property


"Nicholas Paldino [.NET/C# MVP]" <nicholas...@exisconsulting.com> wrote

in message news:OUtKVls$CHA....@TK2MSFTNGP10.phx.gbl...

Nicholas Paldino [.NET/C# MVP]

unread,
Apr 9, 2003, 3:09:55 PM4/9/03
to
John,

If the property is returning a string, you can perform a query of all
instances of CIM_LogicalDevice where the DeviceID is equal to the Dependent
property.


--
- Nicholas Paldino [.NET/C# MVP]
- nicholas...@exisconsulting.com

"John Smith" <som...@microsoft.com> wrote in message

news:eilvJqs$CHA....@TK2MSFTNGP12.phx.gbl...

John Smith

unread,
Apr 9, 2003, 3:25:44 PM4/9/03
to
There is no deviceid property for Win32_IDEControllerDevice... so it just
gives me a invalid query error....

the deviceID property is only for the CIM_LogicalDevice which i can't seem
to get too..

but maybe i am missing something... can u give me a code example...

thankz for all the quick replies...

"Nicholas Paldino [.NET/C# MVP]" <nicholas...@exisconsulting.com> wrote

in message news:#fozGws$CHA....@TK2MSFTNGP11.phx.gbl...

Nicholas Paldino [.NET/C# MVP]

unread,
Apr 9, 2003, 3:56:47 PM4/9/03
to
John,

It's like a join between two database tables. The Dependent property is
returning an id (foreign key) which corresponds to the DeviceID property on
instances of CIM_LogicalDevice (the primary key). So you have to formulate
a new query that will select the appropriate instances from
CIM_LogicalDevice where the DeviceID is whatever the Dependent is, like
this:

select * from CIM_LogicalDevice where DeviceID = <Dependent>


--
- Nicholas Paldino [.NET/C# MVP]
- nicholas...@exisconsulting.com

"John Smith" <som...@microsoft.com> wrote in message

news:O2b244s$CHA...@TK2MSFTNGP10.phx.gbl...

John Smith

unread,
Apr 11, 2003, 10:19:47 AM4/11/03
to
that kinda worked ... thankz for all the help

"Nicholas Paldino [.NET/C# MVP]" <nicholas...@exisconsulting.com> wrote

in message news:#4vxSKt$CHA....@TK2MSFTNGP11.phx.gbl...

weitzh...@gmail.com

unread,
Oct 4, 2011, 4:10:09 PM10/4/11
to
I tried Selecting from USBControlerDevice, but it only gives me installed devices.

How do I get the following info:
1) Is currently connected to PC?
2) Friendly name (i.e. Apple iPod Touch, Sansa Clip etc.)
0 new messages