首先要新增「引用」乙個dll,選擇「system management」;
再引入2個命名空間:
using system.management;
using system.io;
foreach迴圈:宣告乙個迭代變數自動獲取陣列中每個元素的值。
string.format:格式化字元,本站就有解釋。
**:form1.cs
private void button1_click(object sender, eventargs e)
myinfo += mycpuid;
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
}private void button2_click(object sender, eventargs e)
catch
}messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
}private void button3_click(object sender, eventargs e)
catch
}messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
}private void button4_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
}private void button5_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
}private void button6_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
private void button7_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
private void button8_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
private void button9_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
private void button10_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
private void button11_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);
private void button14_click(object sender, eventargs e)
messagebox.show(myinfo, "資訊提示", messageboxbuttons.ok, messageboxicon.information);}}
}
form1.designer.cs
private system.componentmodel.icontainer components = null;
///
/// 清理所有正在使用的資源。
///
/// 如果應釋放託管資源,為 true;否則為 false。
protected override void dispose(bool disposing)
base.dispose(disposing);
}#region windows 窗體設計器生成的**
///
/// 設計器支援所需的方法 - 不要
/// 使用**編輯器修改此方法的內容。
///
#endregion
private system.windows.forms.button button1;
private system.windows.forms.button button2;
private system.windows.forms.button button3;
private system.windows.forms.button button4;
private system.windows.forms.button button5;
private system.windows.forms.button button6;
private system.windows.forms.button button7;
private system.windows.forms.button button8;
private system.windows.forms.button button9;
private system.windows.forms.button button10;
private system.windows.forms.button button11;
private system.windows.forms.button button14;
private system.windows.forms.label label1;}}
cpu資訊獲取
cpu溫度的獲取 cpu溫度儲存在 sys class thermal thermal zone0 temp中,讀取出的數值需要除以1000。bash 工具 cat 工具用來強制讀取乙個檔案。gerp 工具用來篩選資料。awk 用來處理資料。uptime 獲取cpu負載資訊 bash 數值計算 ba...
C 獲取CPU資訊
include windows.h include iostream include string using namespace std 用來儲存資訊 dword deax dword debx dword decx dword dedx void execpuid dword veax 初始化c...
mac獲取cpu資訊
物理cpu數量,可以數不重複的 physical id 有幾個 邏輯cpu數量 物理cpu數量 x cpu cores 這個規格值 x 2 如果支援並開啟ht 備註一下 linux下top檢視的cpu也是邏輯cpu個數 一般來說,物理cpu個數 每顆核數就應該等於邏輯cpu的個數,如果不相等的話,則...