[EXPLORER_NEW]
authorThomas Faber <thomas.faber@reactos.org>
Sun, 6 Jan 2013 10:08:10 +0000 (10:08 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sun, 6 Jan 2013 10:08:10 +0000 (10:08 +0000)
- Correctly load and save advanced setting(s). Patch by Edijs Kolesnikovičs.
CORE-6835 #resolve

svn path=/trunk/; revision=58122

reactos/base/shell/explorer-new/CMakeLists.txt
reactos/base/shell/explorer-new/explorer.c
reactos/base/shell/explorer-new/precomp.h
reactos/base/shell/explorer-new/settings.c [new file with mode: 0644]
reactos/base/shell/explorer-new/trayntfy.c
reactos/base/shell/explorer-new/trayprop.c

index b2494a8..173c065 100644 (file)
@@ -5,6 +5,7 @@ list(APPEND SOURCE
     desktop.c
     dragdrop.c
     explorer.c
+    settings.c
     startmnu.c
     taskband.c
     taskswnd.c
index cfa01d1..7e77ff9 100644 (file)
@@ -370,6 +370,7 @@ _tWinMain(IN HINSTANCE hInstance,
 
     hExplorerInstance = hInstance;
     hProcessHeap = GetProcessHeap();
+    LoadAdvancedSettings();
 
     hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
     if (hUser32 != NULL)
index 4c9ddd2..47c84dc 100644 (file)
 #include "initguid.h"
 #include "undoc.h"
 
-/* Structure to hold non-default options*/
-typedef struct _ADVANCED_SETTINGS {
-    BOOL bShowSeconds;
-} ADVANCED_SETTINGS, *PADVANCED_SETTINGS;
-
-extern ADVANCED_SETTINGS AdvancedSettings;
-
 /* dynamic imports due to lack of support in msvc linker libs */
 typedef INT (APIENTRY *REGSHELLHOOK)(HWND, DWORD);
 #ifdef UNICODE
@@ -241,6 +234,26 @@ TrayProcessMessages(IN OUT ITrayWindow *Tray);
 VOID
 TrayMessageLoop(IN OUT ITrayWindow *Tray);
 
+/*
+ * settings.c
+ */
+
+/* Structure to hold non-default options*/
+typedef struct _ADVANCED_SETTINGS {
+    BOOL bShowSeconds;
+} ADVANCED_SETTINGS, *PADVANCED_SETTINGS;
+
+extern ADVANCED_SETTINGS AdvancedSettings;
+extern const TCHAR szAdvancedSettingsKey[];
+
+VOID
+LoadAdvancedSettings(VOID);
+
+BOOL
+SaveSettingDword(IN PCTSTR pszKeyName,
+                 IN PCTSTR pszValueName,
+                 IN DWORD dwValue);
+
 /*
  * trayprop.h
  */
diff --git a/reactos/base/shell/explorer-new/settings.c b/reactos/base/shell/explorer-new/settings.c
new file mode 100644 (file)
index 0000000..3c17dd2
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * ReactOS Explorer
+ *
+ * Copyright 2013 - Edijs Kolesnikovics
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <precomp.h>
+
+ADVANCED_SETTINGS AdvancedSettings;
+const TCHAR szAdvancedSettingsKey[] = TEXT("Software\\ReactOS\\Features\\Explorer");
+
+
+VOID
+LoadAdvancedSettings(VOID)
+{
+    HKEY hKey;
+
+    /* Set defaults */
+    AdvancedSettings.bShowSeconds = FALSE;
+
+    /* Check registry */
+    if (RegOpenKey(HKEY_CURRENT_USER, szAdvancedSettingsKey, &hKey) == ERROR_SUCCESS)
+    {
+        DWORD dwValue, dwValueLength, dwType;
+
+        dwValueLength = sizeof(dwValue);
+        if (RegQueryValueEx(hKey, TEXT("ShowSeconds"), NULL, &dwType, (PBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD)
+            AdvancedSettings.bShowSeconds = dwValue != 0;
+
+        RegCloseKey(hKey);
+    }
+}
+
+BOOL
+SaveSettingDword(IN PCTSTR pszKeyName,
+                 IN PCTSTR pszValueName,
+                 IN DWORD dwValue)
+{
+    BOOL ret = FALSE;
+    HKEY hKey;
+
+    if (RegCreateKey(HKEY_CURRENT_USER, pszKeyName, &hKey) == ERROR_SUCCESS)
+    {
+        ret = RegSetValueEx(hKey, pszValueName, 0, REG_DWORD, (PBYTE)&dwValue, sizeof(dwValue)) == ERROR_SUCCESS;
+
+        RegCloseKey(hKey);
+    }
+
+    return ret;
+}
+
+/* EOF */
index 023973c..971400a 100644 (file)
@@ -701,25 +701,6 @@ static const struct
     { FALSE, DATE_SHORTDATE, NULL }
 };
 
-HRESULT RegGetDWord(HKEY hKey, LPCTSTR szValueName, DWORD * lpdwResult)
-{
-    LONG lResult;
-    DWORD dwDataSize = sizeof(DWORD);
-    DWORD dwType = 0;
-
-    // Check input parameters...
-    if (hKey == NULL || lpdwResult == NULL) return E_INVALIDARG;
-
-    // Get dword value from the registry...
-    lResult = RegQueryValueEx(hKey, szValueName, 0, &dwType, (LPBYTE) lpdwResult, &dwDataSize );
-
-    // Check result and make sure the registry value is a DWORD(REG_DWORD)...
-    if (lResult != ERROR_SUCCESS) return HRESULT_FROM_WIN32(lResult);
-    else if (dwType != REG_DWORD) return DISP_E_TYPEMISMATCH;
-
-    return NOERROR;
-}
-
 #define CLOCKWND_FORMAT_COUNT (sizeof(ClockWndFormats) / sizeof(ClockWndFormats[0]))
 
 #define TRAY_CLOCK_WND_SPACING_X    0
index 28853d0..9b69818 100644 (file)
@@ -30,8 +30,6 @@ typedef struct _PROPSHEET_INFO
     HBITMAP hTaskbarBitmap;
 } PROPSHEET_INFO, *PPROPSHEET_INFO;
 
-ADVANCED_SETTINGS AdvancedSettings = { FALSE };
-
 
 static BOOL
 UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
@@ -225,6 +223,7 @@ AdvancedSettingsPageProc(HWND hwndDlg,
 
                 case PSN_APPLY:
                     AdvancedSettings.bShowSeconds = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SECONDS);
+                    SaveSettingDword(szAdvancedSettingsKey, TEXT("ShowSeconds"), AdvancedSettings.bShowSeconds);
                     break;
             }