查看WMI的NAMESPACE
发表于:2007-06-30来源:作者:点击数:
标签:
This tutorial allows you to see what WMI namespaces and classes are on your system. When you want to use the WMI classes in .NET you need to add a reference to the System.Management .NET namespace. Then you also need to add a reference in y
This tutorial allows you to see what WMI namespaces and classes are on your system. When you want to use the WMI classes in .NET you need to add a reference to the System.Management .NET namespace. Then you also need to add a reference in your source code:
using System.Management;
The code in this tutorial consists of a function to get the namespaces and a function to get the classes. If you don@#t specify a namespace then root is used. Make sure to specify root when you try to go to the next namespace in the hierarchy. For example:
BrowseWMI rootCIMV2
The code to get the namespaces is below:
ManagementScope ms = new ManagementScope (strFrom);
ManagementPath mp = new ManagementPath("__namespace");
ManagementClass mClass = new ManagementClass (ms, mp, null);
foreach (ManagementObject mo in mClass.GetInstances())
{
Console.WriteLine (" " + mo["Name"]);
}
The code is pretty self explanatory and the classes code is very similar.
That@#s all there is to it.
原文转自:http://www.ltesting.net