.NET 4.x [C#+WMI]Можно ли через WMI узнать температуру процессора и ядер?
Формулировка задачи:
[C#+WMI]Можно ли через WMI узнать температуру процессора и ядер?
Щас лопачу сайты вожусь но русскоязычной документации по WMI нету
А тем более по таким вопросам.
Этот код выводит смарты но нечего близкого к показателям эвереста и других прог нету.
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData WHERE Active=True"); foreach (ManagementObject obj in searcher.Get()) { byte[] vendorSpec = obj["VendorSpecific"] as byte[]; for (int i = 0; i < 362; i++) if (vendorSpec != null) { listBox1.Items.Add(((5.0 / 9.0) * (vendorSpec[i]-32)).ToString()); } }
Решение задачи: «.NET 4.x [C#+WMI]Можно ли через WMI узнать температуру процессора и ядер?»
textual
Листинг программы
using System.Management;// добавить ссылку public partial class Form1 : Form { public Form1() { InitializeComponent(); this.comboBox1.Items.AddRange(new object[] { "Win32_1394Controller", "Win32_1394ControllerDevice", "Win32_BaseBoard", "Win32_Battery", "Win32_BIOS", "Win32_Bus", "Win32_CDROMDrive", "Win32_CIMLogicalDeviceCIMDataFile", "Win32_DeviceBus", "Win32_DeviceMemoryAddress", "Win32_DeviceSettings", "Win32_DisplayConfiguration", "Win32_DisplayControllerConfiguration", "Win32_DMAChannel", "Win32_DriverVXD", "Win32_FloppyController", "Win32_FloppyDrive", "Win32_HeatPipe", "Win32_IDEController", "Win32_IDEControllerDevice", "Win32_InfraredDevice", "Win32_IRQResource", "Win32_Keyboard", "Win32_MotherboardDevice", "Win32_OnBoardDevice", "Win32_PCMCIAController", "Win32_PNPAllocatedResource", "Win32_PnPDevice", "Win32_PnPEntity", "Win32_PointingDevice", "Win32_PortableBattery", "Win32_PortConnector", "Win32_PortResource", "Win32_POTSModem", "Win32_POTSModemToSerialPort", "Win32_PowerManagementEvent", "Win32_Printer", "Win32_PrinterConfiguration", "Win32_PrinterController", "Win32_PrinterDriverDll", "Win32_PrinterSetting", "Win32_PrinterShare", "Win32_PrintJob", "Win32_Processor", "Win32_SCSIController", "Win32_SCSIControllerDevice", "Win32_SerialPort", "Win32_SerialPortConfiguration", "Win32_SerialPortSetting", "Win32_SMBIOSMemory", "Win32_SoundDevice", "Win32_TemperatureProbe", "Win32_USBController", "Win32_USBControllerDevice", "Win32_VideoConfiguration", "Win32_VideoController", "Win32_VideoSettings", "Win32_VoltageProbe"}); // comboBox1.SelectedItem = "Win32_Processor"; comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string result = string.Empty; ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from " + comboBox1.SelectedItem.ToString()); try { foreach (ManagementObject share in searcher.Get()) { foreach (PropertyData PC in share.Properties) { if (PC.Value != null && PC.Value.ToString() != "") { switch (PC.Value.GetType().ToString()) { case "System.String[]": string[] str = (string[])PC.Value; string str2 = ""; foreach (string st in str) str2 += st + " "; result += share["Name"].ToString() + " -> " + str2 + Environment.NewLine; break; case "System.UInt16[]": ushort[] shortData = (ushort[])PC.Value; string tstr2 = ""; foreach (ushort st in shortData) tstr2 += st.ToString() + " "; result += share["Name"].ToString() + " -> " + tstr2 + Environment.NewLine; break; default: result += share["Name"].ToString() + " -> " + PC.Value.ToString() + Environment.NewLine; break; } } } } MessageBox.Show(result); } catch { } } }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д