首页 > 系统相关 >Qt获取windows下的CPU序号

Qt获取windows下的CPU序号

时间:2022-12-07 09:47:26浏览次数:45  
标签:Qt get windows serialnumber cpu wmic result CPU QString

 

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 processorid
    //查询主板序列号:wmic baseboard get serialnumber
    //查询BIOS序列号:wmic bios get serialnumber
    //查看硬盘:wmic diskdrive get serialnumber
    QProcess p;
    p.start(cmd);
    p.waitForFinished();
    QString result = QString::fromLocal8Bit(p.readAllStandardOutput());
    QStringList list = cmd.split(" ");
    result = result.remove(list.last(), Qt::CaseInsensitive);
    result = result.replace("\r", "");
    result = result.replace("\n", "");
    result = result.simplified();
    return result;
}
 
QString frmMain::getCpuName()
{
    return getWMIC("wmic cpu get name");
}
 
QString frmMain::getCpuId()
{
    return getWMIC("wmic cpu get processorid");
}
 
QString frmMain::getDiskNum()
{
    return getWMIC("wmic diskdrive where index=0 get serialnumber");
}

转载于:https://www.shuzhiduo.com/A/xl56jB645r/

标签:Qt,get,windows,serialnumber,cpu,wmic,result,CPU,QString
From: https://www.cnblogs.com/tingtaishou/p/16962158.html

相关文章