const int bufSize = 4096;
HANDLE hChildStd_OUT_Rd = NULL,
hChildStd_OUT_Wr = NULL;
TCHAR win32cmd = TEXT("tempcmd /cpu");
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
CreatePipe(&hChildStd_OUT_Rd, &hChildStd_OUT_Wr, &saAttr, 0);
SetHandleInformation(hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0);
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.hStdOutput = hChildStd_OUT_Wr;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
CreateProcess(NULL, win32cmd, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &siStartInfo, &piProcInfo);
BOOL bSuccess = FALSE;
bSuccess = ReadFile(hChildStd_OUT_Rd, chBuf, bufSize, &dwRead, NULL);
if(!bSuccess || dwRead == 0)
Not ready to be put into XBMC or anything but it gets the gist of it. Problem is, ReadFile() just hangs in ntdll.dll. Not having much skill in C++ I have no idea what I'm doing wrong, so I fear this is as far as I'll get.
Regarding DDDamian's code, that would make a great fallback if m_cpuTempCmd is empty, so that people with boards that expose temp via WMI don't have to do anything, but those with boards that don't like jhsrennie can set their own command.
As an aside, I noticed that the temperatures are only taken upon first entering the system info menu, unlike all the other stats that are updated every second or so whilst in the menu. Perhaps temperatures should be updated in the same way?
EDIT: I have this code in a #ifdef _WIN32 at line 364 in xbmc\utils\CPUInfo.cpp, btw.