C# 使用 PerformanceCounter 获取 CPU 和 硬盘的使用率: 先看界面: 建一个 Windows Form 桌面程序,代码如下: using System; using System.ComponentModel; using System.Windows.Forms; using System.Diagnostics; using System.Threading; namespace PerformanceCounterApp { public partial cla…
<pre name="code" class="csharp"> using System; using System.Collections; using System.Management; public class OneProgram { public static void Main() { Console.WriteLine("HostName:{0}", HardwareInfo.GethostName()); Cons…
windows下执行命令除了用cmd之外,还有个东西叫WMIC,非常强大,可以通过他获取很多信息,包括硬件信息. QString frmMain::getWMIC(const QString &cmd) { //获取cpu名称:wmic cpu get Name //获取cpu核心数:wmic cpu get NumberOfCores //获取cpu线程数:wmic cpu get NumberOfLogicalProcessors //查询cpu序列号:wmic cpu get proces…
using System;using System.Management; namespace MmPS.Common.Helper{ /// <summary> /// 获取计算机相关的信息 /// </summary> public class Computer { public static string CpuID; //1.cpu序列号 public static string MacAddress; //2.mac序列号 public static string Dis…