[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    [PATCH 2/2] winecfg: Add /v parameter to display current Windows version.
From:       Owen Rudge <orudge () codeweavers ! com>
Date:       2020-08-31 22:11:39
Message-ID: a527da36-d74b-7b02-b89d-2881f5a74d27 () codeweavers ! com
[Download RAW message or body]

This patch allows winecfg to be called with the "/v" parameter to 
display the current Windows version. "/v winver" will continue to allow 
the Windows version to be updated.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49242
Signed-off-by: Owen Rudge <orudge@codeweavers.com>
---
  programs/winecfg/appdefaults.c | 24 +++++++++++++++++++++++-
  programs/winecfg/main.c        |  9 +++++++--
  programs/winecfg/winecfg.h     |  1 +
  3 files changed, 31 insertions(+), 3 deletions(-)



["0002-winecfg-Add-v-parameter-to-display-current-Windows-v.patch" (text/x-patch)]

diff --git a/programs/winecfg/appdefaults.c b/programs/winecfg/appdefaults.c
index dd3480cd635..8068941ff87 100644
--- a/programs/winecfg/appdefaults.c
+++ b/programs/winecfg/appdefaults.c
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
+#include "wine/heap.h"
 #include "wine/unicode.h"
 #include "winecfg.h"
 #include "resource.h"
@@ -74,6 +75,8 @@ static const struct win_version win_versions[] =
 #endif
 };
 
+#define DEFAULT_WIN_VERSION   "win7"
+
 static const char szKey9x[] = "Software\\Microsoft\\Windows\\CurrentVersion";
 static const char szKeyNT[] = "Software\\Microsoft\\Windows NT\\CurrentVersion";
 static const char szKeyProdNT[] = "System\\CurrentControlSet\\Control\\ProductOptions";
@@ -146,7 +149,7 @@ static void update_comboboxes(HWND dialog)
             return;
         }
         if (ver != -1) winver = strdupA( win_versions[ver].szVersion );
-        else winver = strdupA("win7");
+        else winver = strdupA(DEFAULT_WIN_VERSION);
     }
     WINE_TRACE("winver is %s\n", winver);
 
@@ -498,6 +501,25 @@ void print_windows_versions(void)
     }
 }
 
+void print_current_winver(void)
+{
+    char *winver = get_reg_key(config_key, keypath(""), "Version", "");
+
+    if (!winver || !winver[0])
+    {
+        int ver = get_registry_version();
+
+        if (ver == -1)
+            printf(DEFAULT_WIN_VERSION "\n");
+        else
+            printf("%s\n", win_versions[ver].szVersion);
+    }
+    else
+        printf("%s\n", winver);
+
+    heap_free(winver);
+}
+
 static void on_winver_change(HWND dialog)
 {
     int selection = SendDlgItemMessageW(dialog, IDC_WINVER, CB_GETCURSEL, 0, 0);
diff --git a/programs/winecfg/main.c b/programs/winecfg/main.c
index f29e2f036fb..76885d4fd74 100644
--- a/programs/winecfg/main.c
+++ b/programs/winecfg/main.c
@@ -187,9 +187,13 @@ ProcessCmdLine(LPSTR lpCmdLine)
     {
         return -1;
     }
-    if ((lpCmdLine[1] == 'V' || lpCmdLine[1] == 'v') && (lstrlenA(lpCmdLine) > 4))
+    if (lpCmdLine[1] == 'V' || lpCmdLine[1] == 'v')
     {
-        return set_winver_from_string(&lpCmdLine[3]) ? 0 : 1;
+        if (lstrlenA(lpCmdLine) > 4)
+            return set_winver_from_string(&lpCmdLine[3]) ? 0 : 1;
+
+        print_current_winver();
+        return 0;
     }
 
     if (lpCmdLine[1] == '?')
@@ -197,6 +201,7 @@ ProcessCmdLine(LPSTR lpCmdLine)
         printf("Usage: winecfg [options]\n\n");
         printf("Options:\n");
         printf("  [no option] Launch the graphical version of this program.\n");
+        printf("  /v          Displays the current global Windows version.\n");
         printf("  /v version  Set global Windows version to 'version'.\n");
         printf("  /?          Display this information and exit.\n\n");
         printf("Valid versions for 'version':\n\n");
diff --git a/programs/winecfg/winecfg.h b/programs/winecfg/winecfg.h
index 9dd39c51c3f..d022cd3d688 100644
--- a/programs/winecfg/winecfg.h
+++ b/programs/winecfg/winecfg.h
@@ -91,6 +91,7 @@ INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
 
 /* Windows version management */
 BOOL set_winver_from_string(const char *version);
+void print_current_winver(void);
 void print_windows_versions(void);
 
 /* Drive management  */



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic