如何获得特定路径下的WMI类列表(使用c#)

本文关键字:列表 使用 WMI 何获得 路径 | 更新日期: 2023-09-27 18:17:32

对于C#,如何获得WMI在特定路径下的类列表,如root'WMI

如何获得特定路径下的WMI类列表(使用c#)

这可能对你有帮助

http://msdn.microsoft.com/en-US/library/ms257362%28v=vs.80%29.aspx

编辑:

On function addclasssestolist

private void AddClassesToList(object o)
{
    this.statusValue.Text = "Searching...";
    try
    {
        // Perform WMI object query on 
        // selected namespace.
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(
            new ManagementScope(
            namespaceValue.Text),
            new WqlObjectQuery(
            "select * from meta_class"),
            null);
        foreach (ManagementClass wmiClass in
            searcher.Get())
        {
            this.classList.Items.Add(
                wmiClass["__CLASS"].ToString());
            count++;
        }
        this.statusValue.Text =
            count + " classes found.";
    }
    catch (ManagementException ex)
    {
        this.statusValue.Text = ex.Message;
    }
}

这部分:

ManagementObjectSearcher searcher =
new ManagementObjectSearcher(
new ManagementScope(
"root/default"/*Replace this with your namespace*/),
new WqlObjectQuery(
"select * from meta_class"),
null);
相关文章: