資源簡介
WMI 獲取計算機信息(cpu 硬盤 網卡 網速)C# 源碼

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Net;
using?System.Net.NetworkInformation;
using?System.Collections;
using?System.Management;
namespace?WINInfo
{
????public?partial?class?Form1?:?Form
????{?
????????public?ManagementScope?RemoteScope;//遠程連接
????????public?ManagementScope?LocalScope;?//本機連接
????????public?bool?bLocalFlg;?//本機初始化標識
????????public?bool?bRemoteFlg;
????????public?Form1()
????????{
????????????InitializeComponent();
????????????bLocalFlg?=?true;
????????????bRemoteFlg?=?true;
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????}
????????private?void?GetWinInfo_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????if?(bRemoteFlg)
????????????????{
????????????????????//判斷遠程是否能連接
????????????????????Ping?pingSender?=?new?Ping();?//Ping既然是類,為何不變色?
????????????????????PingReply?reply?=?pingSender.Send(this.TextIP.Text);
????????????????????if?(reply.Status?==?IPStatus.Success)
????????????????????{
????????????????????????string?message?=?string.Format(“地址:{0}連接測試成功!“?this.TextIP.Text);
????????????????????????MessageBox.Show(message);
????????????????????}
????????????????????else
????????????????????{
????????????????????????string?message?=?string.Format(“地址:{0}連接測試失敗!“?this.TextIP.Text);
????????????????????????MessageBox.Show(message);
????????????????????????ListViewItem?Item1?=?new?ListViewItem(new?string[]?{?this.TextIP.Text?““?““?““?““?“““連接失敗“?}?-1);
????????????????????????this.ListRec.Items.Add(Item1);
????????????????????????return;
????????????????????}
????????????????????//連接
????????????????????ConnectionOptions?connection?=?new?ConnectionOptions();
????????????????????connection.Username?=?this.TextUserName.Text;
????????????????????connection.Password?=?this.TextPassword.Text;
????????????????????connection.Authority?=?“ntlmdomain:“;
????????????????????string?strPath?=?“\\\\“+this.TextIP.Text?+?“\\root\\CIMV2“;
????????????????????RemoteScope?=?new?ManagementScope(
????????????????????????strPath??connection);
????????????????????RemoteScope.Connect();
????????????????????bRemoteFlg?=?false;
????????????????}
????????????????
????????????????//?獲取物理內存
????????????????string?strMemory?=?““;
????????????????objectQuery?query?=?new?objectQuery(“SELECT?*?FROM?Win32_OperatingSystem“);
????????????????ManagementobjectSearcher?searcher?=
????????????????????new?ManagementobjectSearcher(RemoteScope?query);
????????????????foreach?(Managementobject?queryObj?in?searcher.Get())
????????????????{
????????????????????double?nTotalMer?=?Convert.ToDouble(queryObj[“TotalVisibleMemorySize“]);
????????????????????double?nFreeMer?=?Convert.ToDouble(queryObj[“FreePhysicalMemory“]);
??????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????40960??2012-09-17?09:59??獲取計算機性能數據\WINInfo\bin\Debug\Interop.MMC20.dll
?????文件??????16896??2012-09-20?10:41??獲取計算機性能數據\WINInfo\bin\Debug\WINInfo.exe
?????文件??????32256??2012-09-20?10:41??獲取計算機性能數據\WINInfo\bin\Debug\WINInfo.pdb
?????文件??????14328??2012-09-20?10:42??獲取計算機性能數據\WINInfo\bin\Debug\WINInfo.vshost.exe
?????文件????????490??2007-07-21?02:33??獲取計算機性能數據\WINInfo\bin\Debug\WINInfo.vshost.exe.manifest
?????文件??????14012??2012-09-20?10:41??獲取計算機性能數據\WINInfo\Form1.cs
?????文件??????10434??2012-09-20?10:41??獲取計算機性能數據\WINInfo\Form1.Designer.cs
?????文件???????5814??2012-09-20?10:41??獲取計算機性能數據\WINInfo\Form1.resx
?????文件??????40960??2012-09-17?09:59??獲取計算機性能數據\WINInfo\obj\Debug\Interop.MMC20.dll
?????文件????????730??2012-09-20?10:42??獲取計算機性能數據\WINInfo\obj\Debug\WINInfo.csproj.FileListAbsolute.txt
?????文件????????847??2012-09-20?10:41??獲取計算機性能數據\WINInfo\obj\Debug\WINInfo.csproj.GenerateResource.Cache
?????文件????????544??2012-09-17?09:59??獲取計算機性能數據\WINInfo\obj\Debug\WINInfo.csproj.ResolveComReference.cache
?????文件??????16896??2012-09-20?10:41??獲取計算機性能數據\WINInfo\obj\Debug\WINInfo.exe
?????文件????????180??2012-09-20?10:41??獲取計算機性能數據\WINInfo\obj\Debug\WINInfo.Form1.resources
?????文件??????32256??2012-09-20?10:41??獲取計算機性能數據\WINInfo\obj\Debug\WINInfo.pdb
?????文件????????180??2012-09-17?10:01??獲取計算機性能數據\WINInfo\obj\Debug\WINInfo.Properties.Resources.resources
?????文件????????488??2012-09-17?09:15??獲取計算機性能數據\WINInfo\Program.cs
?????文件???????1356??2012-09-17?09:15??獲取計算機性能數據\WINInfo\Properties\AssemblyInfo.cs
?????文件???????2864??2012-09-17?09:15??獲取計算機性能數據\WINInfo\Properties\Resources.Designer.cs
?????文件???????5612??2012-09-17?09:15??獲取計算機性能數據\WINInfo\Properties\Resources.resx
?????文件???????1092??2012-09-17?09:15??獲取計算機性能數據\WINInfo\Properties\Settings.Designer.cs
?????文件????????249??2012-09-17?09:15??獲取計算機性能數據\WINInfo\Properties\Settings.settings
?????文件????????378??2012-09-17?09:50??獲取計算機性能數據\WINInfo\UserControl1.cs
?????文件???????1118??2012-09-17?09:50??獲取計算機性能數據\WINInfo\UserControl1.Designer.cs
?????文件???????4209??2012-09-17?10:01??獲取計算機性能數據\WINInfo\WINInfo.csproj
?????文件????????911??2012-09-17?09:15??獲取計算機性能數據\WINInfo.sln
????..A..H.?????16896??2012-09-20?10:09??獲取計算機性能數據\WINInfo.suo
?????目錄??????????0??2012-09-20?10:45??獲取計算機性能數據\WINInfo\obj\Debug\Refactor
?????目錄??????????0??2012-09-20?10:45??獲取計算機性能數據\WINInfo\obj\Debug\TempPE
?????目錄??????????0??2012-09-20?10:45??獲取計算機性能數據\WINInfo\bin\Debug
............此處省略10個文件信息
- 上一篇:C#線程間操作無效Study
- 下一篇:FitLine.cs
評論
共有 條評論