1
我想創建一個應用程序的Windows 8使用C#顯示我當前的電池電量。我試圖查詢win32_battery類的相關屬性,但我得到了一個不尋常的結果。這裏是我的代碼:試圖訪問電池級別,C#
private void btn1_Click(object sender, EventArgs e)
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Battery");
ManagementObjectCollection collection = searcher.Get();
foreach (ManagementObject obj in collection)
{
txtBox.AppendText(obj.ToString() + "\r\n");
};
}
我在txtBox唯一的結果就是
\\MIKESLAPTOP\root\cimv2:Win32_Battery.DeviceID=" ASUSTeKX401-44"
任何想法,爲什麼我只是讀theDevideID財產?所有的指導非常感謝。
相關的問題:http://stackoverflow.com/questions/5716559/get-battery-info-without-wmi – Raptor
當您嘗試命令'是什麼顯示的Get-在PowerShell控制檯中的WmiObject Win32_Battery'? –