Windows获取系统唯一标识UUID  (也叫CSP UUID)

 

命令行

wmic csproduct get uuid

 

C/C++

使用CoCreateGuid函数,可以参考官方:https://docs.microsoft/en-us/windows/win32/api/combaseapi/nf-combaseapi-cocreateguid

 

C#

using System.Management;
string GetSystemId()
{
    string systemId = null;
    using (ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_ComputerSystemProduct"))
    {
        foreach(var item in mos.Get())
        {
            systemId = item["UUID"].ToString();
        }
    }
    return systemId;
}