Steve Teeples said:
I would like to display in a listbox all possible paths that can be fed
into
the ManagementClass constructor (e.g., Win32_Enviroment,
Win32_OperatingSystem, etc.) Can someone steer me in the direction of how
to
generate such a list from within a C# application?
This should dump all local root namespaces classes:
string cimRoot = "root\\";
ManagementClass nsClass = new ManagementClass(
new ManagementScope(@"root"),
new ManagementPath("__namespace"),
null);
foreach(ManagementObject ns in nsClass.GetInstances()) {
Console.WriteLine(cimRoot + ns["Name"].ToString());
ManagementClass newClass = new ManagementClass(cimRoot +
ns["Name"].ToString());
EnumerationOptions options = new EnumerationOptions();
options.EnumerateDeep = true; // set to false if only the root
classes are needed
ManagementObjectCollection moc = newClass.GetSubclasses(options);
foreach(ManagementObject o in moc) {
if(o["__SuperClass"] == null)
Console.WriteLine(o["__Class"]);
else
Console.WriteLine("\t" + o["__Class"]);
}
}
}
Willy.