From: norbert.bizet Date: Tue, 12 Apr 2022 11:48:00 +0000 (-0400) Subject: windows: change windows os version detection X-Git-Tag: Beta-15.0.0~596 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4977e018d99dd360f84038bb81872db61a3a4750;p=thirdparty%2Fbacula.git windows: change windows os version detection --- diff --git a/bacula/src/win32/libwin32/main.cpp b/bacula/src/win32/libwin32/main.cpp index 9aa2c58bd..80838c2bf 100644 --- a/bacula/src/win32/libwin32/main.cpp +++ b/bacula/src/win32/libwin32/main.cpp @@ -415,9 +415,11 @@ bool GetWindowsVersionString(LPTSTR osbuf, int maxsiz) return false; } p += size-1; - *p++ = ' '; - *p++ = '('; } + + bstrncat(osbuf, " (build ", maxsiz); + p += 8; + hr = RegQueryValueExA(currentVersionKey, "CurrentBuild", NULL, &type, NULL, &size); if (hr == ERROR_MORE_DATA || hr == ERROR_SUCCESS) { hr = RegQueryValueExA(currentVersionKey, "CurrentBuild", NULL, &type, (LPBYTE)p, &size); @@ -427,5 +429,26 @@ bool GetWindowsVersionString(LPTSTR osbuf, int maxsiz) p += size-1; *p++ = ')'; } + + hr = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", 0, KEY_ALL_ACCESS, ¤tVersionKey); + if (hr != ERROR_SUCCESS) { + return false; + } + + char buf[80]; + hr = RegQueryValueExA(currentVersionKey, "PROCESSOR_ARCHITECTURE", NULL, &type, NULL, &size); + if (hr == ERROR_MORE_DATA || hr == ERROR_SUCCESS) { + hr = RegQueryValueExA(currentVersionKey, "PROCESSOR_ARCHITECTURE", NULL, &type, (LPBYTE)buf, &size); + if (hr != ERROR_SUCCESS) { + return false; + } + if (strstr(buf,"64")) { + bstrncat(osbuf, TEXT(", 64-bit"), maxsiz); + } else { + bstrncat(osbuf, TEXT(", 32-bit"), maxsiz); + } + + p += 8; + } return true; }