public static CPUInfo getInfo() { CPUInfo info = new CPUInfo(); foreach (var item in new System.Management.ManagementObjectSearcher("Select * from Win32_ComputerSystem").Get()) { info.ownerName = (string)item["Name"]; } foreach (var item in new ManagementObjectSearcher("select * from Win32_Processor").Get()) { if (item != null) { info.cpuFrequency = item["MaxClockSpeed"].ToString(); info.numLogicalProcessors = item["NumberOfLogicalProcessors"].ToString(); info.cpuModel = (string)item["Name"]; } } //Out.put(info.ownerName); //Out.put(info.numLogicalProcessors); //Out.put(info.cpuFrequency); //Out.put(info.cpuModel); return(info); }
public void sendCPUInfo(NetworkStream stream) { CPUInfo info = CPUManager.getInfo(); info.status = "READY"; var serializer = new JavaScriptSerializer(); var result = serializer.Serialize(info); var streamWriter = new StreamWriter(stream); streamWriter.WriteLine(result); streamWriter.Flush(); Out.put("Sent CPUinfo to host"); }