ReactOS  0.4.12-dev-51-ge94618b
settings.c File Reference
#include "precomp.h"
#include <winreg.h>
#include <windowsx.h>
#include <tchar.h>
Include dependency graph for settings.c:

Go to the source code of this file.

Functions

LONG QueryStringValue (HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen)
 
void LoadSettings (void)
 
void SaveSettings (void)
 

Variables

const TCHAR g_szGeneralRegKey [] = _T("Software\\Microsoft\\CharMap")
 
HWND hWnd
 

Function Documentation

◆ LoadSettings()

void LoadSettings ( void  )

Definition at line 53 of file settings.c.

Referenced by ScreenSaverConfigureDialog().

54 {
55  HKEY hKey = NULL;
56  int iItemIndex = -1;
57 
59  {
60  TCHAR szBuffer[MAX_PATH];
61  DWORD dwAdvancedChecked;
62  unsigned long type = REG_DWORD, size = 1024;
63 
64  /* Restore last selected font */
65  if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("Font"), szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))) == ERROR_SUCCESS)
66  {
67  //Get combobox handle
69 
70  //Search for match and return index if match found
71  iItemIndex = ComboBox_FindStringExact(hWnd, -1, szBuffer);
72  if(iItemIndex != CB_ERR)
73  {
74  ComboBox_SetCurSel(hWnd, iItemIndex);
76  }
77  }
78 
79  /* Restore last selected character set */
80  if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("CodePage"), szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))) == ERROR_SUCCESS)
81  {
82  //Get combobox handle
84 
85  iItemIndex = ComboBox_FindStringExact(hWnd, -1, szBuffer);
86  if(iItemIndex != CB_ERR)
87  {
88  ComboBox_SetCurSel(hWnd, iItemIndex);
89  }
90  }
91 
92  RegQueryValueEx(hKey, _T("Advanced"), NULL, &type, (LPBYTE)&dwAdvancedChecked, &size);
93 
94  if(dwAdvancedChecked != FALSE)
96 
97  RegCloseKey(hKey);
98  }
99  else
100  {
101  /* Default font seems to be Arial */
103 
104  iItemIndex = ComboBox_FindStringExact(hWnd, -1, _T("Arial"));
105  if(iItemIndex != CB_ERR)
106  {
107  ComboBox_SetCurSel(hWnd, iItemIndex);
109  }
110  }
111 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDC_CHECK_ADVANCED
Definition: resource.h:26
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HWND hWnd
Definition: settings.c:17
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define SendDlgItemMessage
Definition: winuser.h:5708
#define IDC_COMBO_CHARSET
Definition: resource.h:21
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ComboBox_FindStringExact(hwndCtl, indexStart, lpszFind)
Definition: windowsx.h:22
unsigned char * LPBYTE
Definition: typedefs.h:52
const TCHAR g_szGeneralRegKey[]
Definition: settings.c:16
smooth NULL
Definition: ftsmooth.c:416
#define CB_ERR
Definition: winuser.h:2389
#define MF_CHECKED
Definition: winuser.h:132
char TCHAR
Definition: xmlstorage.h:189
#define BM_CLICK
Definition: winuser.h:1878
#define _T(x)
Definition: vfdio.h:22
GLsizeiptr size
Definition: glext.h:5919
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:41
#define IDC_FONTCOMBO
Definition: resource.h:12
VOID ChangeMapFont(HWND hDlg)
Definition: charmap.c:113
LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen)
Definition: settings.c:19
#define RegOpenKeyEx
Definition: winreg.h:520
HWND hCharmapDlg
Definition: charmap.c:22
#define REG_DWORD
Definition: sdbapi.c:539

◆ QueryStringValue()

LONG QueryStringValue ( HKEY  hKey,
LPCTSTR  lpSubKey,
LPCTSTR  lpValueName,
LPTSTR  pszBuffer,
DWORD  dwBufferLen 
)

Definition at line 19 of file settings.c.

Referenced by LoadSettings(), ATL::CRegKey::QueryGUIDValue(), and SuggestKeys().

20 {
21  LONG lResult;
22  HKEY hSubKey = NULL;
23  DWORD cbData, dwType;
24 
25  if (lpSubKey)
26  {
27  lResult = RegOpenKey(hKey, lpSubKey, &hSubKey);
28  if (lResult != ERROR_SUCCESS)
29  goto done;
30  hKey = hSubKey;
31  }
32 
33  cbData = (dwBufferLen - 1) * sizeof(*pszBuffer);
34  lResult = RegQueryValueEx(hKey, lpValueName, NULL, &dwType, (LPBYTE) pszBuffer, &cbData);
35  if (lResult != ERROR_SUCCESS)
36  goto done;
37  if (dwType != REG_SZ)
38  {
39  lResult = -1;
40  goto done;
41  }
42 
43  pszBuffer[cbData / sizeof(*pszBuffer)] = _T('\0');
44 
45 done:
46  if (lResult != ERROR_SUCCESS)
47  pszBuffer[0] = _T('\0');
48  if (hSubKey)
49  RegCloseKey(hSubKey);
50  return lResult;
51 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKey
Definition: winreg.h:519
#define REG_SZ
Definition: layer.c:22

◆ SaveSettings()

void SaveSettings ( void  )

Definition at line 113 of file settings.c.

Referenced by LoadSettings(), and ScreenSaverConfigureDialog().

114 {
115  HKEY hKey = NULL;
116 
118  {
119  TCHAR szBuffer[MAX_PATH];
120 
122  ComboBox_GetText(hWnd, szBuffer, MAX_PATH);
123 
124  if(*szBuffer != '\0')
125  RegSetValueEx(hKey, _T("Font"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) MAX_PATH);
126 
128  ComboBox_GetText(hWnd, szBuffer, MAX_PATH);
129 
130  if(*szBuffer != '\0')
131  RegSetValueEx(hKey, _T("CodePage"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) MAX_PATH);
132 
133  RegSetValueEx(hKey, _T("Advanced"), 0, REG_DWORD, (LPBYTE)&Settings.IsAdvancedView, (DWORD) sizeof(DWORD));
134 
135  RegCloseKey(hKey);
136  }
137 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HWND hWnd
Definition: settings.c:17
#define ComboBox_GetText(hwndCtl, lpch, cchMax)
Definition: windowsx.h:33
SSSTARS Settings
Definition: settings.c:33
#define IDC_COMBO_CHARSET
Definition: resource.h:21
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
const TCHAR g_szGeneralRegKey[]
Definition: settings.c:16
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_FONTCOMBO
Definition: resource.h:12
HWND hCharmapDlg
Definition: charmap.c:22
#define REG_DWORD
Definition: sdbapi.c:539
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define REG_SZ
Definition: layer.c:22

Variable Documentation

◆ g_szGeneralRegKey

const TCHAR g_szGeneralRegKey[] = _T("Software\\Microsoft\\CharMap")

Definition at line 16 of file settings.c.

Referenced by GetFindFlags(), LoadSettings(), SaveSettings(), and SetFindFlags().

◆ hWnd

HWND hWnd

Definition at line 17 of file settings.c.

Referenced by ATL::_ATL_MSG::_ATL_MSG(), _scwprintf(), AddContentTab(), AddOrUpdateHwnd(), CTaskSwitchWnd::AddTask(), ANIMATE_Create(), AppletInit(), ShellPath::assign(), AVISaveOptionsFmtChoose(), BrsFolder_OnCreate(), BUTTON_WindowProc(), ButtonWndProc_common(), CBRollUp(), ChildWndProc(), co_IntCallEventProc(), co_IntCallSentMessageCallback(), co_IntDoSendMessage(), co_IntPaintWindows(), co_IntSendMessageWithCallBack(), co_IntSetActiveWindow(), co_IntSetForegroundAndFocusWindow(), co_IntSetForegroundMessageQueue(), co_IntTranslateAccelerator(), co_IntUpdateWindows(), co_UserCreateWindowEx(), co_UserDestroyWindow(), COMBO_ItemOp(), COMBO_KillFocus(), COMBO_LButtonDown(), Control_DoWindow(), Control_LoadApplet(), Control_WndProc_Create(), ATL::CWindow::Create(), ATL::CDialogImpl< CConfirmReplace >::Create(), ATL::CWindowImplBaseT< CToolbar< TASK_ITEM >, CControlWinTraits >::Create(), Entry::create_absolute_pidl(), create_async_message_window(), create_window(), CreateApplicationWindow(), CreateLocationsList(), CreateMainWindow(), ATL::CWindow::CWindow(), D3DTests(), DDTests(), DECLARE_INTERFACE_(), ATL::CWindow::Detach(), DeviceCreateHardwarePageEx(), DIALOG_Browse(), DialogBoxIndirectParamAorW(), ATL::CDialogImplBaseT< CWindow >::DialogProc(), DlgMainProc(), DoSaveFileAs(), EditChild_WndProc(), EditProc(), EditWndProc_common(), EndTask(), EngCreateWnd(), EnumJoysticks(), FD31_DirListDblClick(), FD31_DiskChange(), FD31_FileListSelect(), FD31_TestPath(), FD31_Validate(), FD31_WMInitDialog(), FlashWindow(), FlushMessages(), FreeLdrPageWndProc(), FreeResources(), get_iwnd(), GetClassLongW(), ATL::CWindow::GetDescendantWindowCallback(), GetDlgItemTextA(), GetDlgItemTextW(), CSysTray::GetHWnd(), GetLastActivePopup(), GraphCtrl_Create(), GuiConsoleHandleNcCreate(), HEXEDIT_WM_NCCREATE(), HH_AddHTMLPane(), HH_AddNavigationPane(), HH_AddSizeBar(), HH_CreateHelpWindow(), ICONTITLE_Create(), ImmAssociateContext(), ImmGetContext(), CBaseBarSite::Initialize(), CDesktopFolderEnum::Initialize(), InitInstance(), InitInstance_wave(), InitOpenFileName(), InitThreads(), InstallWizard(), IntCallWindowProcA(), IntCallWindowProcW(), IntCallWndProc(), IntCallWndProcRet(), IntCreateWindow(), IntGetMenuItemRect(), IntRegisterShellHookWindow(), IntRestoreTebWndCallback(), IntSetTebWndCallback(), InvalidateCell(), is_ime_window_proc(), CMenuFocusManager::IsTrackedWindowOrParent(), IsWindowActive(), joySetCapture(), MACRO_History(), MainProc(), MCIQTZ_mciWhere(), MCIWND_Create(), MCIWndProc(), MDI_GetWindow(), MessageBoxExA(), MessageBoxExW(), MessageBoxRes(), MessageBoxTimeoutA(), MessageBoxTimeoutW(), MessageBoxWithResStringW(), MIXER_WCallback(), MsqCalculateMessageTime(), MsqSetStateWindow(), NC_HandleNCRButtonDown(), NtGdiSetPixelFormat(), NtGdiSwapBuffers(), NtUserCallHwndOpt(), NtUserCreateCaret(), NtUserGetClipboardOwner(), NtUserGetClipboardViewer(), NtUserGetDCEx(), NtUserGetOpenClipboardWindow(), NtUserHideCaret(), NtUserMessageCall(), NtUserSetLogonNotifyWindow(), NtUserSetWindowLong(), NtUserShowCaret(), OnNcCreate(), CLayerUIPropPage::OnPageRelease(), OnSetFont(), open_and_empty_clipboard_thread(), open_clipboard_thread(), OpenURL(), pointer_default(), post_message_thread(), PrintRegistryHive(), PrintUIEntryW(), CMenuSite::ProcessWindowMessage(), CCPLItemMenu::QueryContextMenu(), ScreenSaverProc(), send_message_thread(), SendMessageCallbackA(), SendMessageTimeoutA(), SendMessageTimeoutW(), SendNotifyMessageA(), SetFileName(), SHCreateWorkerWindowA(), SHCreateWorkerWindowW(), ShellEntry::ShellEntry(), ShellExecuteA(), SHInvokeCommand(), ShowStatusMessageThread(), SPY_EnterMessage(), SPY_ExitMessage(), SPY_GetMsgName(), START_TEST(), ATL::CDialogImplBaseT< CWindow >::StartDialogProc(), ATL::CWindowImplBaseT< CToolbar< TASK_ITEM >, CControlWinTraits >::StartWindowProc(), ATL::CContainedWindowT< TBase, TWinTraits >::StartWindowProc(), ATL::CWindowImplBaseT< CToolbar< TASK_ITEM >, CControlWinTraits >::SubclassWindow(), ATL::CContainedWindowT< TBase, TWinTraits >::SubclassWindow(), test_CoWaitForMultipleHandles(), test_CoWaitForMultipleHandles_thread(), Test_CreateDialogW(), test_default_ime_disabled_cb(), test_dtm_get_monthcal(), test_dtm_set_and_get_mccolor(), test_dtm_set_and_get_mcfont(), test_dtm_set_and_get_range(), test_dtm_set_and_get_system_time(), test_dtm_set_and_get_systemtime_with_limits(), test_dtm_set_format(), test_dtm_set_range_swap_min_max(), test_edit_control_3(), test_edit_control_5(), test_edit_control_6(), test_events(), Test_Focus(), Test_GetClipBox(), Test_GetClipRgn(), Test_GetCurrentObject(), test_GetWindowTheme(), test_initial_state(), test_listbox_dlgdir(), test_menu_hilitemenuitem(), test_menu_input(), test_menu_input_thread(), Test_Messages(), Test_Messages_Child(), Test_Messages_MDI(), Test_Messages_MDI_Child(), Test_OneParamRoutine_MapDesktopObject(), Test_OneParamRoutine_WindowFromDC(), test_OpenThemeData(), test_OpenThemeDataEx(), test_pack_APPBARDATA(), test_pack_NOTIFYICONDATAA(), test_pack_NOTIFYICONDATAW(), Test_Params(), Test_RealGetWindowClass(), Test_ScrollDC(), Test_ScrollWindowEx(), Test_SendInput(), test_SetWindowTheme(), test_TBS_AUTOTICKS(), Test_UnaffectedMessages(), test_wm_set_get_text(), test_write_watch(), TestOwnership(), ThemeHandleNcMouseMove(), ThemeInitDrawContext(), ToolTipProc(), TreeListEditLabel(), TreeListProc(), TreeListStartAutoEdit(), TreeListStartNotifyEdit(), UserGethWnd(), UserRealizePalette(), VerifyWnd(), VfdToolTip(), WDML_RemoveConv(), WIN_ListChildren(), CDefView::WindowProc(), CShellBrowser::WindowProc(), ATL::CWindowImplBaseT< CToolbar< TASK_ITEM >, CControlWinTraits >::WindowProc(), ATL::CContainedWindowT< TBase, TWinTraits >::WindowProc(), WINHELP_HistoryWndProc(), WINHELP_MainWndProc(), WinMain(), wmain(), WndProc(), WOWShellExecute(), WSAAsyncGetHostByAddr(), WSAAsyncGetHostByName(), WSAAsyncGetProtoByName(), WSAAsyncGetProtoByNumber(), WSAAsyncGetServByName(), WSAAsyncGetServByPort(), WSPAsyncSelect(), wWinMain(), and CMenuSite::~CMenuSite().