de7540655ef28c1ddaffc623ba8e77fb16cb557e
[reactos.git] / reactos / base / shell / explorer / settings.cpp
1 /*
2 * ReactOS Explorer
3 *
4 * Copyright 2013 - Edijs Kolesnikovics
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "precomp.h"
22
23 TASKBAR_SETTINGS TaskBarSettings;
24 const WCHAR szAdvancedSettingsKey[] = L"Software\\ReactOS\\Features\\Explorer";
25
26 VOID
27 LoadTaskBarSettings(VOID)
28 {
29 HKEY hKey;
30
31 /* Set defaults */
32 TaskBarSettings.bLock = TRUE;
33 TaskBarSettings.bAutoHide = FALSE;
34 TaskBarSettings.bAlwaysOnTop = FALSE;
35 TaskBarSettings.bGroupButtons = TRUE;
36 TaskBarSettings.bShowQuickLaunch = TRUE;
37 TaskBarSettings.bShowClock = TRUE;
38 TaskBarSettings.bShowSeconds = FALSE;
39 TaskBarSettings.bHideInactiveIcons = TRUE;
40
41 /* Check registry */
42 if (RegOpenKeyW(HKEY_CURRENT_USER, szAdvancedSettingsKey, &hKey) == ERROR_SUCCESS)
43 {
44 DWORD dwValue, dwValueLength, dwType;
45
46 dwValueLength = sizeof(dwValue);
47 if (RegQueryValueExW(hKey, L"ShowSeconds", NULL, &dwType, (PBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD)
48 TaskBarSettings.bShowSeconds = dwValue != 0;
49
50 RegCloseKey(hKey);
51 }
52 }
53
54 VOID
55 SaveTaskBarSettings(VOID)
56 {
57 SaveSettingDword(szAdvancedSettingsKey, TEXT("ShowSeconds"), TaskBarSettings.bShowSeconds);
58 }
59
60 BOOL
61 SaveSettingDword(IN LPCWSTR pszKeyName,
62 IN LPCWSTR pszValueName,
63 IN DWORD dwValue)
64 {
65 BOOL ret = FALSE;
66 HKEY hKey;
67
68 if (RegCreateKeyW(HKEY_CURRENT_USER, pszKeyName, &hKey) == ERROR_SUCCESS)
69 {
70 ret = RegSetValueExW(hKey, pszValueName, 0, REG_DWORD, (PBYTE)&dwValue, sizeof(dwValue)) == ERROR_SUCCESS;
71
72 RegCloseKey(hKey);
73 }
74
75 return ret;
76 }
77
78 /* EOF */