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;
373 int CPUInfo[4] = {-1};
374 char CPUBrandString[0x40];
375 __cpuid(CPUInfo, 0x80000000);
376 unsigned int nExIds = CPUInfo[0];
377 memset(CPUBrandString, 0,
sizeof(CPUBrandString));
378 for (
unsigned int i=0x80000000; i<=nExIds; ++i)
384 memcpy(CPUBrandString, CPUInfo,
sizeof(CPUInfo));
385 else if (i == 0x80000003)
386 memcpy(CPUBrandString + 16, CPUInfo,
sizeof(CPUInfo));
387 else if (i == 0x80000004)
388 memcpy(CPUBrandString + 32, CPUInfo,
sizeof(CPUInfo));
391 return CPUBrandString;
397 SYSTEM_INFO siSysInfo;
398 GetSystemInfo(&siSysInfo);
399 std::ostringstream oss;
400 oss << siSysInfo.dwNumberOfProcessors;
407 std::ostringstream oss;
408 DISPLAY_DEVICE devInfo;
409 devInfo.cb =
sizeof(DISPLAY_DEVICE);
410 DWORD loopDevNum = 0;
411 std::map<std::string, int> foundMap;
412 while (EnumDisplayDevices(
NULL, loopDevNum, &devInfo, 0))
414 std::string name = devInfo.DeviceString;
415 if (foundMap.find(name) == foundMap.end())
417 if (foundMap.empty() ==
false)
431 MEMORYSTATUSEX statex;
432 statex.dwLength =
sizeof (statex);
433 GlobalMemoryStatusEx (&statex);
435 int64_t memtotalbytes = statex.ullTotalPhys;
436 int64_t memfreebytes = statex.ullAvailPhys;
437 int64_t memusedbytes = memtotalbytes - memfreebytes;
439 std::string unitsLabel;
440 double divisor = 1.0;
457 divisor = 1073741824.0;
461 std::ostringstream t,u,f;
462 t << int64_t(memtotalbytes / divisor) <<
" " << unitsLabel;
463 u << int64_t(memusedbytes / divisor) <<
" " << unitsLabel;
464 f << int64_t(memfreebytes / divisor) <<
" " << unitsLabel;
476 outVal = aja::read_registry_string(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
479 outVal = aja::read_registry_string(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
488 std::ostringstream oss;
489 std::string key_path =
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
490 oss << aja::read_registry_string(HKEY_LOCAL_MACHINE, key_path,
"CurrentBuild") <<
491 "." << aja::read_registry_dword(HKEY_LOCAL_MACHINE, key_path,
"UBR");
501 path.append(getenv(
"SystemDrive"));
502 path.append(
"\\Users\\");
503 if (username.find(
'\\') != std::string::npos)
506 path.append(username.substr(username.find(
'\\') + 1));
510 path.append(username);
603 bool usernameFound =
false;
609 HRESULT hresult = SHGetFolderPathA(
NULL, CSIDL_PROFILE,
NULL, SHGFP_TYPE_CURRENT, szPath);
614 std::vector<std::string> parts;
616 std::string username;
617 if (parts.size() > 0)
618 username = parts.at(parts.size()-1);
620 if (!path.empty() && username !=
"systemprofile" && PathFileExistsA(path.c_str()))
621 usernameFound =
true;
628 std::string regVal = aja::read_registry_string(HKEY_CURRENT_USER,
629 "Volatile Environment",
631 if (!regVal.empty() && regVal !=
"SYSTEM")
634 if (!path.empty() && PathFileExistsA(path.c_str()))
635 usernameFound =
true;
642 std::string regVal = aja::read_registry_string(HKEY_LOCAL_MACHINE,
643 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI",
648 if (!path.empty() && PathFileExistsA(path.c_str()))
649 usernameFound =
true;
656 std::string regVal = aja::read_registry_string(HKEY_LOCAL_MACHINE,
657 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
662 if (!path.empty() && PathFileExistsA(path.c_str()))
663 usernameFound =
true;
676 path.append(
"\\AppData\\Local\\AJA\\");
682 r = SHGetFolderPath(
NULL,CSIDL_COMMON_APPDATA,
NULL,0,szPath);
691 PathAppend(szPath, L
"AJA\\");
693 ::wcstombs(tmpPath,szPath,
MAX_PATH);
694 path.append(tmpPath);
696 PathAppend(szPath,
"AJA\\");
700 path.append(
"ntv2\\Firmware\\");