Qt获取系统核心数量
int getSysKernalNum(){
QEventLoop loop;
QProcess command;
int num = 0;
QObject::connect(&command,QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished),[&loop](){
loop.quit();
});
QObject::connect(&command,&QProcess::readyReadStandardOutput,[&command,&num](){
QString str = QString(command.readAllStandardOutput()) ;
QRegExp reg("[0-9]{1,2}");
int pos =reg.indexIn(str);
QString kernalnum = str.mid(pos,reg.matchedLength());
num = kernalnum.toInt();
});
command.start("wmic cpu get NumberOfCores");
loop.exec();
return num!=0 ? num:4;
};
*获取其他系统信息(线程数,系统名等)同样可以通过上述的方式