Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find all tables used in ManagementObjectSearcher in win32 API

Tags:

c#

winapi

wmi

I was getting curious to know various classes/tables that can be queried for ManagementObject to read hardware details.

e.g.

ManagementObjectSearcher adapters = 
new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter");

i.e.

1. Win32_NetworkAdapter
2. Win32_LogicalDisk
3. Win32_Service

Where can I find whole list of such tables.

like image 569
Shantanu Gupta Avatar asked Dec 01 '14 11:12

Shantanu Gupta


2 Answers

You could select appropriate tables from the following list: http://msdn.microsoft.com/en-us/library/aa389273(v=vs.85).aspx

You could also get this list programmatically:

ManagementObjectSearcher wmi = new ManagementObjectSearcher
    ("SELECT * FROM meta_class WHERE __CLASS LIKE 'Win32_%'");
foreach (ManagementObject obj in wmi.Get())
    Console.WriteLine(obj["__CLASS"]);
like image 50
Dmitry Avatar answered Nov 01 '22 10:11

Dmitry


Microsoft's WMI Code Creator is handy for this, its a utility that lists all WMI classes in a searchable fashion, it will generate VBScript code you can run immediately to see whats actually returned and you can then use it to spit out C#/VB.Net code snippets.

enter image description here

like image 43
Alex K. Avatar answered Nov 01 '22 11:11

Alex K.