/// <summary>
/// 获得cpu序列号
/// </summary>
/// <returns></returns>
public static string GetProcessorId()
{
string cmdThreadResponse = string.Empty;
CmdThread cmdThread = new CmdThread();
cmdThread.Exit += CmdThread_Exit;
cmdThread.Start("wmic cpu get processorid");
while (string.IsNullOrEmpty(cmdThreadResponse)) ;
string head = "ProcessorId";
int pos = cmdThreadResponse.IndexOf(head);
if (pos < 0) throw new System.Exception("无法获取设备ID!");
string ans = cmdThreadResponse.Substring(pos + head.Length);
if (string.IsNullOrEmpty(ans)) throw new System.Exception("设备ID为空!");
ans = ans.Trim();
ans = ans.Replace(" ", "");
ans = ans.Replace("\r\n", "/");
return ans;
}
c#获取cpu序列号