[SYSDM]
authorGed Murphy <gedmurphy@reactos.org>
Wed, 9 Dec 2009 16:34:05 +0000 (16:34 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Wed, 9 Dec 2009 16:34:05 +0000 (16:34 +0000)
- Add a setting to the system control panel applet which allows users to force reactos to report as a workstation.
- This is a usermode change only, it will not alter the kernel nor anything calling kernel apis (e.g. RtlGetVersion)
- This change should allow applications which don't allow installation on non-workstation version to install.
See issue #5003 for more details.

svn path=/trunk/; revision=44487

reactos/dll/cpl/sysdm/advanced.c
reactos/dll/cpl/sysdm/lang/en-US.rc
reactos/dll/cpl/sysdm/resource.h

index 8b76057..4cc19b1 100644 (file)
  * FILE:        dll/cpl/sysdm/advanced.c
  * PURPOSE:     Memory, start-up and profiles settings
  * COPYRIGHT:   Copyright Thomas Weidenmueller <w3seek@reactos.org>
-                Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
+                Copyright 2006 - 2009 Ged Murphy <gedmurphy@reactos.org>
  *
  */
 
 #include "precomp.h"
 
 static TCHAR BugLink[] = _T("http://www.reactos.org/bugzilla");
+static TCHAR ReportAsWorkstationKey[] = _T("SYSTEM\\CurrentControlSet\\Control\\ReactOS\\Settings\\Version");
+
+
+static VOID
+OnOK(HWND hwndDlg)
+{
+    HKEY hKey;
+    DWORD ReportAsWorkstation;
+
+    ReportAsWorkstation = (SendDlgItemMessageW(hwndDlg,
+                                               IDC_REPORTASWORKSTATION,
+                                               BM_GETCHECK,
+                                               0,
+                                               0) == BST_CHECKED);
+
+    if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
+                       ReportAsWorkstationKey,
+                       0,
+                       NULL,
+                       0,
+                       KEY_WRITE,
+                       NULL,
+                       &hKey,
+                       NULL) == ERROR_SUCCESS)
+    {
+        RegSetValueEx(hKey,
+                      _T("ReportAsWorkstation"),
+                      0,
+                      REG_DWORD,
+                      (LPBYTE)&ReportAsWorkstation,
+                      sizeof(DWORD));
+    }
+}
+
+static VOID
+OnInitSysSettingsDialog(HWND hwndDlg)
+{
+    HKEY hKey;
+    DWORD dwVal;
+    DWORD dwType = REG_DWORD;
+    DWORD cbData = sizeof(DWORD);
+
+    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                     ReportAsWorkstationKey,
+                     0,
+                     KEY_READ,
+                     &hKey) == ERROR_SUCCESS)
+    {
+        if (RegQueryValueEx(hKey,
+                            _T("ReportAsWorkstation"),
+                            0,
+                            &dwType,
+                            (LPBYTE)&dwVal,
+                            &cbData) == ERROR_SUCCESS)
+        {
+            if (dwVal == TRUE)
+            {
+                // set the check box
+                SendDlgItemMessageW(hwndDlg,
+                                    IDC_REPORTASWORKSTATION,
+                                    BM_SETCHECK,
+                                    BST_CHECKED,
+                                    0);
+            }
+        }
+    }
+
+
+}
+
+INT_PTR CALLBACK
+SysSettingsDlgProc(HWND hwndDlg,
+                   UINT uMsg,
+                   WPARAM wParam,
+                   LPARAM lParam)
+{
+    UNREFERENCED_PARAMETER(lParam);
+
+    switch (uMsg)
+    {
+        case WM_INITDIALOG:
+            OnInitSysSettingsDialog(hwndDlg);
+            break;
+
+        case WM_COMMAND:
+            switch (LOWORD(wParam))
+            {
+                case IDOK:
+                    OnOK(hwndDlg);
+                    EndDialog(hwndDlg, 0);
+                    return TRUE;
+            }
+            break;
+    }
+
+    return FALSE;
+}
+
 
 /* Property page dialog callback */
 INT_PTR CALLBACK
@@ -51,6 +149,13 @@ AdvancedPageProc(HWND hwndDlg,
                               (DLGPROC)StartRecDlgProc);
                     break;
 
+                case IDC_SYSSETTINGS:
+                    DialogBox(hApplet,
+                              MAKEINTRESOURCE(IDD_SYSSETTINGS),
+                              hwndDlg,
+                              (DLGPROC)SysSettingsDlgProc);
+                    break;
+
                 case IDC_ENVVAR:
                     DialogBox(hApplet,
                               MAKEINTRESOURCE(IDD_ENVIRONMENT_VARIABLES),
index dcec9b1..c677637 100644 (file)
@@ -62,10 +62,22 @@ BEGIN
     LTEXT       "Startup and recovery options tell your computer how to start and what to do if an error causes your computer to stop.", IDC_STATIC, 16, 144, 228, 19
     PUSHBUTTON  "Settings", IDC_STAREC, 194, 162, 50, 15
 
-    PUSHBUTTON  "Environment Variables", IDC_ENVVAR, 84, 192, 80, 15
+    PUSHBUTTON  "System Settings", IDC_SYSSETTINGS, 2, 192, 80, 15
+    PUSHBUTTON  "Environment Variables", IDC_ENVVAR, 85, 192, 80, 15
     PUSHBUTTON  "Error Reporting", IDC_ERRORREPORT, 170, 192, 80, 15
 END
 
+IDD_SYSSETTINGS DIALOGEX 0, 0, 221, 106
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
+CAPTION "System Settings"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+    GROUPBOX        "Version Info",IDC_STATIC,6,3,210,53
+    CONTROL         "Report as Workstation",IDC_REPORTASWORKSTATION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,37,88,10
+    LTEXT           "ReactOS is built as a server OS and reports as such. Check this box to change this for applications only.",IDC_STATIC,15,15,183,21
+    PUSHBUTTON      "OK",IDOK,166,63,50,14
+END
+
 
 IDD_HARDWAREPROFILES DIALOGEX 6, 18, 254, 234
 STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
index e282179..14e2c3f 100644 (file)
 
 /* propsheet - advanced */
 #define IDD_PROPPAGEADVANCED            400
-#define IDC_ENVVAR                      401
-#define IDC_STAREC                      402
-#define IDC_PERFOR                      403
-#define IDC_USERPROFILE                 404
-#define IDC_ERRORREPORT                 405
-
+#define IDC_SYSSETTINGS                 401
+#define IDC_ENVVAR                      402
+#define IDC_STAREC                      403
+#define IDC_PERFOR                      404
+#define IDC_USERPROFILE                 405
+#define IDC_ERRORREPORT                 406
+
+/* system settings */
+#define IDD_SYSSETTINGS                 800
+#define IDC_REPORTASWORKSTATION         801
 
 /* user profiles */
 #define IDD_USERPROFILE                 500