]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
windows: change windows os version detection
authornorbert.bizet <norbert.bizet@baculasystems.com>
Tue, 12 Apr 2022 11:48:00 +0000 (07:48 -0400)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:58 +0000 (13:56 +0200)
bacula/src/win32/libwin32/main.cpp

index 9aa2c58bdb6511068a76d42ca3bd27e707692a51..80838c2bf56269e7b5d2dd52832409eb7a3af196 100644 (file)
@@ -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, &currentVersionKey);
+   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;
 }