13 #pragma warning(disable:4996)
16 #include <Knownfolders.h>
36 { 5, 0, (
char*)
"Windows 2000", (
char*)
"Windows 2000"},
37 { 5, 1, (
char*)
"Windows XP", (
char*)
"Windows XP"},
38 { 5, 2, (
char*)
"Windows Server 2003", (
char*)
"Windows Server 2003"},
39 { 6, 0, (
char*)
"Windows Vista", (
char*)
"Windows Server 2008"},
40 { 6, 1, (
char*)
"Windows 7", (
char*)
"Windows Server 2008 R2"},
41 { 6, 2, (
char*)
"Windows 8", (
char*)
"Windows Server 2012"},
42 { 6, 3, (
char*)
"Windows 8.1", (
char*)
"Windows Server 2012 R2"}
51 std::string key_path =
"HARDWARE\\DESCRIPTION\\System\\BIOS";
53 outVal = aja::read_registry_string(HKEY_LOCAL_MACHINE, key_path,
"SystemManufacturer");
54 if (outVal.empty() ==
false)
56 outVal += aja::read_registry_string(HKEY_LOCAL_MACHINE, key_path,
"SystemProductName");
57 if (outVal.empty() ==
false)
59 outVal += aja::read_registry_string(HKEY_LOCAL_MACHINE, key_path,
"SystemFamily");
60 if (outVal.empty() ==
false)
70 std::string key_path =
"HARDWARE\\DESCRIPTION\\System\\BIOS";
71 outVal = aja::read_registry_string(HKEY_LOCAL_MACHINE, key_path,
"BIOSVendor");
72 if (outVal.empty() ==
false)
74 outVal += aja::read_registry_string(HKEY_LOCAL_MACHINE, key_path,
"BIOSVersion");
75 if (outVal.empty() ==
false)
77 outVal += aja::read_registry_string(HKEY_LOCAL_MACHINE, key_path,
"BIOSReleaseDate");
86 TCHAR buffer[256] = TEXT(
"");
87 DWORD dwSize = MAX_COMPUTERNAME_LENGTH*2;
88 if (GetComputerNameEx(ComputerNameDnsHostname, buffer, &dwSize))
100 li.QuadPart = GetTickCount64() * 10000;
103 sinceBoot.dwLowDateTime = li.LowPart;
104 sinceBoot.dwHighDateTime = li.HighPart;
107 GetLocalTime(&stNow);
110 SystemTimeToFileTime(&stNow, &nowTime);
114 ULARGE_INTEGER nowLi, sinceBootLi, bootTimeLi;
115 nowLi.HighPart = nowTime.dwHighDateTime;
116 nowLi.LowPart = nowTime.dwLowDateTime;
117 sinceBootLi.HighPart = sinceBoot.dwHighDateTime;
118 sinceBootLi.LowPart = sinceBoot.dwLowDateTime;
120 bootTimeLi.QuadPart = nowLi.QuadPart - sinceBootLi.QuadPart;
122 bootTime.dwHighDateTime = bootTimeLi.HighPart;
123 bootTime.dwLowDateTime = bootTimeLi.LowPart;
125 SYSTEMTIME sysBootTime;
126 FileTimeToSystemTime(&bootTime, &sysBootTime);
128 std::ostringstream t;
129 t << std::setfill(
'0') << std::setw(4) << sysBootTime.wYear <<
"-" <<
130 std::setfill(
'0') << std::setw(2) << sysBootTime.wMonth <<
"-" <<
131 std::setfill(
'0') << std::setw(2) << sysBootTime.wDay <<
" " <<
132 std::setfill(
'0') << std::setw(2) << sysBootTime.wHour <<
":" <<
133 std::setfill(
'0') << std::setw(2) << sysBootTime.wMinute <<
":" <<
134 std::setfill(
'0') << std::setw(2) << sysBootTime.wSecond;
145 std::string retVal =
"Microsoft Windows";
148 HRESULT hres = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
149 if (!SUCCEEDED(hres) && hres != RPC_E_CHANGED_MODE) {
155 IWbemLocator *pLoc =
NULL;
156 hres = CoCreateInstance(
159 CLSCTX_INPROC_SERVER,
160 IID_IWbemLocator, (LPVOID *) &pLoc);
168 IWbemServices *pSvc =
NULL;
169 hres = pLoc->ConnectServer(
170 _bstr_t(L
"ROOT\\CIMV2"),
183 IClientSecurity* pSecurity =
NULL;
184 hres = pSvc->QueryInterface(IID_IClientSecurity, (LPVOID*)&pSecurity);
185 if (FAILED(hres) || !pSecurity) {
192 LPOLESTR serverPrincName =
NULL;
193 DWORD authnLevel = 0;
195 RPC_AUTH_IDENTITY_HANDLE authInfo =
NULL;
196 DWORD ifCapabilites = 0;
198 hres = pSecurity->QueryBlanket(pSvc,
211 hres = pSecurity->SetBlanket(pSvc,
215 RPC_C_AUTHN_LEVEL_DEFAULT,
216 RPC_C_IMP_LEVEL_IMPERSONATE,
225 IEnumWbemClassObject* pEnumerator =
NULL;
226 hres = pSvc->ExecQuery(
228 bstr_t(
"SELECT Caption FROM Win32_OperatingSystem"),
229 WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
237 IWbemClassObject *pClsObj =
NULL;
239 hres = pEnumerator->Next(WBEM_INFINITE, 1, &pClsObj, &uReturn);
240 if(FAILED(hres) || 0 == uReturn) {
246 VariantInit(&vtProp);
247 hres = pClsObj->Get(L
"Caption", 0, &vtProp, 0, 0);
248 if (SUCCEEDED(hres)) {
249 retVal = _bstr_t(vtProp.bstrVal);
251 VariantClear(&vtProp);
262 if (pEnumerator !=
NULL) {
263 pEnumerator->Release();
266 if (pClsObj !=
NULL) {
280 std::string osname =
"Unknown";
282 OSVERSIONINFOEX osInfo;
283 ZeroMemory(&osInfo,
sizeof(OSVERSIONINFOEX));
284 osInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
285 GetVersionEx((LPOSVERSIONINFO)&osInfo);
287 int majorVersion = (int)osInfo.dwMajorVersion;
288 int minorVersion = (
int)osInfo.dwMinorVersion;
301 if (majorVersion >=6 && minorVersion >= 2)
304 if (NERR_Success == NetWkstaGetInfo(
NULL, 100, &pinfoRawData))
306 WKSTA_INFO_100 *pworkstationInfo = (WKSTA_INFO_100*)pinfoRawData;
307 majorVersion = (int)pworkstationInfo->wki100_ver_major;
308 minorVersion = (
int)pworkstationInfo->wki100_ver_minor;
309 ::NetApiBufferFree(pinfoRawData);
313 bool foundVersion =
false;
319 if (majorVersion == 5 && minorVersion == 2)
322 int ver2 = GetSystemMetrics(SM_SERVERR2);
324 ZeroMemory(&sysInfo,
sizeof(SYSTEM_INFO));
325 GetSystemInfo(&sysInfo);
327 if (osInfo.wSuiteMask & VER_SUITE_WH_SERVER)
328 osname =
"Windows Home Server";
329 else if(osInfo.wProductType == VER_NT_WORKSTATION &&
330 sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
331 osname =
"Windows XP Professional x64 Edition";
333 osname =
"Windows Server 2003";
335 osname =
"Windows Server 2003 R2";
339 if (osInfo.wProductType == VER_NT_WORKSTATION)
364 osname += osInfo.szCSDVersion;
372 std::string CPUBrandString = aja::read_registry_string(HKEY_LOCAL_MACHINE,
373 "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
374 "ProcessorNameString");
375 return CPUBrandString;
381 SYSTEM_INFO siSysInfo;
382 GetSystemInfo(&siSysInfo);
383 std::ostringstream oss;
384 oss << siSysInfo.dwNumberOfProcessors;
391 std::ostringstream oss;
392 DISPLAY_DEVICE devInfo;
393 devInfo.cb =
sizeof(DISPLAY_DEVICE);
394 DWORD loopDevNum = 0;
395 std::map<std::string, int> foundMap;
396 while (EnumDisplayDevices(
NULL, loopDevNum, &devInfo, 0))
398 std::string name = devInfo.DeviceString;
399 if (foundMap.find(name) == foundMap.end())
401 if (foundMap.empty() ==
false)
415 MEMORYSTATUSEX statex;
416 statex.dwLength =
sizeof (statex);
417 GlobalMemoryStatusEx (&statex);
419 int64_t memtotalbytes = statex.ullTotalPhys;
420 int64_t memfreebytes = statex.ullAvailPhys;
421 int64_t memusedbytes = memtotalbytes - memfreebytes;
423 std::string unitsLabel;
424 double divisor = 1.0;
441 divisor = 1073741824.0;
445 std::ostringstream t,u,f;
446 t << int64_t(memtotalbytes / divisor) <<
" " << unitsLabel;
447 u << int64_t(memusedbytes / divisor) <<
" " << unitsLabel;
448 f << int64_t(memfreebytes / divisor) <<
" " << unitsLabel;
460 outVal = aja::read_registry_string(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
463 outVal = aja::read_registry_string(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
472 std::ostringstream oss;
473 std::string key_path =
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
474 oss << aja::read_registry_string(HKEY_LOCAL_MACHINE, key_path,
"CurrentBuild") <<
475 "." << aja::read_registry_dword(HKEY_LOCAL_MACHINE, key_path,
"UBR");
485 path.append(getenv(
"SystemDrive"));
486 path.append(
"\\Users\\");
487 if (username.find(
'\\') != std::string::npos)
490 path.append(username.substr(username.find(
'\\') + 1));
494 path.append(username);
587 bool usernameFound =
false;
593 HRESULT hresult = SHGetFolderPathA(
NULL, CSIDL_PROFILE,
NULL, SHGFP_TYPE_CURRENT, szPath);
598 std::vector<std::string> parts;
600 std::string username;
601 if (parts.size() > 0)
602 username = parts.at(parts.size()-1);
604 if (!path.empty() && username !=
"systemprofile" && PathFileExistsA(path.c_str()))
605 usernameFound =
true;
612 std::string regVal = aja::read_registry_string(HKEY_CURRENT_USER,
613 "Volatile Environment",
615 if (!regVal.empty() && regVal !=
"SYSTEM")
618 if (!path.empty() && PathFileExistsA(path.c_str()))
619 usernameFound =
true;
626 std::string regVal = aja::read_registry_string(HKEY_LOCAL_MACHINE,
627 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI",
632 if (!path.empty() && PathFileExistsA(path.c_str()))
633 usernameFound =
true;
640 std::string regVal = aja::read_registry_string(HKEY_LOCAL_MACHINE,
641 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
646 if (!path.empty() && PathFileExistsA(path.c_str()))
647 usernameFound =
true;
660 path.append(
"\\AppData\\Local\\AJA\\");
666 r = SHGetFolderPath(
NULL,CSIDL_COMMON_APPDATA,
NULL,0,szPath);
675 PathAppend(szPath, L
"AJA\\");
677 ::wcstombs(tmpPath,szPath,
MAX_PATH);
678 path.append(tmpPath);
680 PathAppend(szPath,
"AJA\\");
684 path.append(
"ntv2\\Firmware\\");