bool getDevcieInfo(char* cmd, list<string> &resultList) {
char buffer[BUFFER_SIZE];
bool ret = false;
FILE* pipe = _popen(cmd, "r"); //打开管道,并执行命令
if (!pipe)
return ret;
char *name[20] = { "UUID", "ProcessorId", "SerialNumber" };
int len0 = strlen(name[0]), len1 = strlen(name[1]), len2 = strlen(name[2]);
bool isOk = false;
while (!feof(pipe)) {
if (fgets(buffer, BUFFER_SIZE, pipe)) {
if (strncmp(name[0], buffer, len0) == 0
|| strncmp(name[1], buffer, len1) == 0
|| strncmp(name[2], buffer, len2) == 0) // 能够正确获取信息
{
isOk = true;
continue;
}
if (isOk == false
|| strcmp("\r\n", buffer) == 0) //去掉windows无用的空行
{
continue;
}
ret = true;
resultList.push_back(string(buffer));
}
}
_pclose(pipe); // 关闭管道
return ret;
}
[注意]APP应用上架合规检测服务,协助应用顺利上架!