//读注册表
bool getCpu(string &cpu)
{
HKEY hKey;
DWORD dwRet;
char tcPath[MAX_PATH] = {0};
DWORD dwLen = MAX_PATH * sizeof(char);
dwRet = RegOpenKeyA(HKEY_LOCAL_MACHINE,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\\",&hKey);
if(dwRet == ERROR_SUCCESS)
{
dwRet = RegQueryValueExA(hKey,"ProcessorNameString",NULL,NULL,(BYTE *)tcPath,&dwLen);
if(dwRet == ERROR_SUCCESS)
{
cpu = tcPath;
RegCloseKey(hKey);
return true;
}
RegCloseKey(hKey);
}
return false;
}
//系统api
bool getMem(string &mem)
{
MEMORYSTATUSEX memStatus;
memStatus.dwLength=sizeof(MEMORYSTATUSEX);// must
if(!GlobalMemoryStatusEx(&memStatus))
return false;
char cValue[256];
ZeroMemory(cValue,sizeof(cValue));
sprintf(cValue,"%d MB",memStatus.ullTotalPhys/(1024*1024));
mem = cValue;
return true;
}