如何在C# 中使用WMI 实现远程查询和共享[3]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 smandhgx 的 blog

managementpath p = new managementpath("\\\\servername\\root\\cimv2");  

managementscope ms = new managementscope(p,oconn);

objectquery oq = new objectquery("select * from win32_process");

managementobjectsearcher query1 = new managementobjectsearcher(ms,oq);

managementobjectcollection querycollection1 = query1.get();           

//列举所有对像,并显示在 listbox 中

       foreach (managementobject service in querycollection1)

      {

         // 列表框中显示的是进程的名称和所在路径,当然还有其它信息,比如进程句柄、//进程优先级、现在的运行状态等,我们没有全部列举出来,感兴趣的话您可以自//己试试

        listbox1.items.add("service: " + service["name"] + " filepath: " + service["executablepath"]);

}

本文关键:C#,WMI,.NET
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top