managementobjectsearcher 類
基於指定的查詢檢索管理物件的集合。此類是用於檢索管理資訊的較為常用的入口點之一。例如,它可以用於列舉系統中的所有磁碟驅動器、網路介面卡、程序及更多管理物件,或者用於查詢所有處於活動狀態的網路連線以及暫停的服務等。在例項化之後,此類的例項可以接受在 objectquery 或其派生類中表示的 wmi 查詢作為輸入,並且還可以選擇接受乙個 managementscope(表示執行查詢時所在的 wmi 命名空間)。它還可以接受 enumerationoptions 中的其他高階選項。當呼叫此物件的 get 方法時,managementobjectsearcher在指定的範圍內執行給定的查詢,並返回與 managementobjectcollection 中的查詢匹配的管理物件的集合。
using system;
using system.management;
public class remoteconnect
{public static void main()
{/*// build an options object for the remote connection
// if you plan to connect to the remote
// computer with a different user name
// and password than the one you are currently using
connectionoptions options =
new connectionoptions();
// and then set the options.username and
// options.password properties to the correct values
// and also set
// options.authority = "ntdlmdomain:domain";
// and replace domain with the remote computer's
// domain. you can also use kerberose instead
// of ntdlmdomain.
*/// make a connection to a remote computer.
// replace the "fullcomputername" section of the
// string "\\\\fullcomputername\\root\\cimv2" with
// the full computer name or ip address of the
// remote computer.
managementscope scope =
new managementscope(
"\\\\fullcomputername\\root\\cimv2");
scope.connect();
// use this code if you are connecting with a
// different user name and password:
//// managementscope scope =
// new managementscope(
// "\\\\fullcomputername\\root\\cimv2", options);
// scope.connect();
//query system for operating system information
objectquery query = new objectquery(
"select * from win32_operatingsystem");
managementobjectsearcher searcher =
new managementobjectsearcher(scope,query);
c 獲取計算機資訊
獲取計算機資訊,獲取遠端計算機資訊的時候需要關閉遠端機器的防火牆,否則獲取不到相關資訊。using system using system.collections.generic using system.linq using system.web using system.text using s...
C 獲取計算機資訊GetSystemInfo
效果如下 上面的 獲得system info結構體的資料之後,採用反射我輸出了每個值,該結構體欄位含義如下 dwoemid 已廢棄的成員,保留這個成員是為了向以前版本的windows nt保持相容。從windows nt 3.51和windows 95的預發行版本開始,使用這個成員的子分支 dwpa...
JS獲取計算機資訊
應最近公司新專案要求,在無電腦客戶端情況下,用網頁載入js的方式獲取終端裝置資訊,查詢資料發現可以做到,然而要受部分條件的約束,如下 使用js獲取計算機資訊需要以下條件 使用ie瀏覽器 需要使用到只有ie瀏覽器有的activex控制項 允許activex控制項的執行 用wmi 微軟開放的api介面,...