ReactOS  0.4.13-dev-259-g5ca9c9c
registry.c File Reference
#include <windows.h>
#include <shlobj.h>
#include <richedit.h>
#include "wordpad.h"
Include dependency graph for registry.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define WIN32_LEAN_AND_MEAN
 

Functions

static LRESULT registry_get_handle (HKEY *hKey, LPDWORD action, LPCWSTR subKey)
 
void registry_set_options (HWND hMainWnd)
 
void registry_read_winrect (RECT *rc)
 
void registry_read_maximized (DWORD *bMaximized)
 
static void truncate_path (LPWSTR file, LPWSTR out, LPWSTR pos1, LPWSTR pos2)
 
static void format_filelist_filename (LPWSTR file, LPWSTR out)
 
void registry_read_filelist (HWND hMainWnd)
 
void registry_set_filelist (LPCWSTR newFile, HWND hMainWnd)
 
int reg_formatindex (WPARAM format)
 
void registry_read_options (void)
 
static void registry_read_formatopts (int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[])
 
void registry_read_formatopts_all (DWORD barState[], DWORD wordWrap[])
 
static void registry_set_formatopts (int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[])
 
void registry_set_formatopts_all (DWORD barState[], DWORD wordWrap[])
 

Variables

static const WCHAR key_recentfiles []
 
static const WCHAR key_options [] = {'O','p','t','i','o','n','s',0}
 
static const WCHAR key_settings [] = {'S','e','t','t','i','n','g','s',0}
 
static const WCHAR key_rtf [] = {'R','T','F',0}
 
static const WCHAR key_text [] = {'T','e','x','t',0}
 
static const WCHAR var_file [] = {'F','i','l','e','%','d',0}
 
static const WCHAR var_framerect [] = {'F','r','a','m','e','R','e','c','t',0}
 
static const WCHAR var_barstate0 [] = {'B','a','r','S','t','a','t','e','0',0}
 
static const WCHAR var_wrap [] = {'W','r','a','p',0}
 
static const WCHAR var_maximized [] = {'M','a','x','i','m','i','z','e','d',0}
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 22 of file registry.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 21 of file registry.c.

Function Documentation

◆ format_filelist_filename()

static void format_filelist_filename ( LPWSTR  file,
LPWSTR  out 
)
static

Definition at line 150 of file registry.c.

151 {
152  LPWSTR pos_basename;
153  LPWSTR truncpos1, truncpos2;
154  WCHAR myDocs[MAX_PATH];
155 
157  pos_basename = file_basename(file);
158  truncpos1 = NULL;
159  truncpos2 = NULL;
160 
161  *(pos_basename-1) = 0;
162  if(!lstrcmpiW(file, myDocs) || (lstrlenW(pos_basename) > FILELIST_ENTRY_LENGTH))
163  {
164  truncpos1 = pos_basename;
165  *(pos_basename-1) = '\\';
166  } else
167  {
168  LPWSTR pos;
169  BOOL morespace = FALSE;
170 
171  *(pos_basename-1) = '\\';
172 
173  for(pos = file; pos < pos_basename; pos++)
174  {
175  if(*pos == '\\' || *pos == '/')
176  {
177  if(truncpos1)
178  {
179  if((pos - file + lstrlenW(pos_basename)) > FILELIST_ENTRY_LENGTH)
180  break;
181 
182  truncpos1 = pos;
183  morespace = TRUE;
184  break;
185  }
186 
187  if((pos - file + lstrlenW(pos_basename)) > FILELIST_ENTRY_LENGTH)
188  break;
189 
190  truncpos1 = pos;
191  }
192  }
193 
194  if(morespace)
195  {
196  for(pos = pos_basename; pos >= truncpos1; pos--)
197  {
198  if(*pos == '\\' || *pos == '/')
199  {
200  if((truncpos1 - file + lstrlenW(pos_basename) + pos_basename - pos) > FILELIST_ENTRY_LENGTH)
201  break;
202 
203  truncpos2 = pos;
204  }
205  }
206  }
207  }
208 
209  if(truncpos1 == pos_basename)
210  lstrcatW(out, pos_basename);
211  else if(truncpos1 == truncpos2 || !truncpos2)
212  lstrcatW(out, file);
213  else
214  truncate_path(file, out, truncpos1, truncpos2);
215 }
#define TRUE
Definition: types.h:120
static void truncate_path(LPWSTR file, LPWSTR out, LPWSTR pos1, LPWSTR pos2)
Definition: registry.c:139
#define lstrlenW
Definition: compat.h:407
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
LPWSTR file_basename(LPWSTR path)
Definition: wordpad.c:211
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static FILE * out
Definition: regtests2xml.c:44
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2085
#define FILELIST_ENTRY_LENGTH
Definition: wordpad.h:92
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
WCHAR * LPWSTR
Definition: xmlstorage.h:184
Definition: fci.c:126

Referenced by registry_read_filelist().

◆ reg_formatindex()

int reg_formatindex ( WPARAM  format)

Definition at line 330 of file registry.c.

331 {
332  return (format & SF_TEXT) ? 1 : 0;
333 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define SF_TEXT
Definition: richedit.h:720

Referenced by dialog_viewproperties(), is_bar_visible(), OnCommand(), registry_read_formatopts(), registry_read_formatopts_all(), registry_set_formatopts_all(), set_fileformat(), store_bar_state(), and WinMain().

◆ registry_get_handle()

static LRESULT registry_get_handle ( HKEY hKey,
LPDWORD  action,
LPCWSTR  subKey 
)
static

Definition at line 42 of file registry.c.

43 {
44  LONG ret;
45  static const WCHAR wszProgramKey[] = {'S','o','f','t','w','a','r','e','\\',
46  'M','i','c','r','o','s','o','f','t','\\',
47  'W','i','n','d','o','w','s','\\',
48  'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
49  'A','p','p','l','e','t','s','\\',
50  'W','o','r','d','p','a','d',0};
51  LPWSTR key = (LPWSTR)wszProgramKey;
52 
53  if(subKey)
54  {
55  WCHAR backslash[] = {'\\',0};
57  (lstrlenW(wszProgramKey)+lstrlenW(subKey)+lstrlenW(backslash)+1)
58  *sizeof(WCHAR));
59 
60  if(!key)
61  return 1;
62 
63  lstrcpyW(key, wszProgramKey);
64  lstrcatW(key, backslash);
65  lstrcatW(key, subKey);
66  }
67 
68  if(action)
69  {
71  KEY_READ | KEY_WRITE, NULL, hKey, action);
72  } else
73  {
75  }
76 
77  if(subKey)
79 
80  return ret;
81 }
LONG WINAPI RegCreateKeyExW(IN HKEY hKey, IN LPCWSTR lpSubKey, IN DWORD Reserved, IN LPWSTR lpClass OPTIONAL, IN DWORD dwOptions, IN REGSAM samDesired, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes OPTIONAL, OUT PHKEY phkResult, OUT LPDWORD lpdwDisposition OPTIONAL)
Definition: registry.c:533
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define lstrlenW
Definition: compat.h:407
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
const WCHAR * action
Definition: action.c:7783
#define lstrcpyW
Definition: compat.h:406
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: path.c:42

Referenced by registry_read_filelist(), registry_read_formatopts(), registry_read_maximized(), registry_read_options(), registry_read_winrect(), registry_set_filelist(), registry_set_formatopts(), and registry_set_options().

◆ registry_read_filelist()

void registry_read_filelist ( HWND  hMainWnd)

Definition at line 217 of file registry.c.

218 {
219  HKEY hFileKey;
220 
222  {
223  WCHAR itemText[MAX_PATH+3], buffer[MAX_PATH];
224  /* The menu item name is not the same as the file name, so we need to store
225  the file name here */
226  static WCHAR file1[MAX_PATH], file2[MAX_PATH], file3[MAX_PATH], file4[MAX_PATH];
227  WCHAR numFormat[] = {'&','%','d',' ',0};
228  LPWSTR pFile[] = {file1, file2, file3, file4};
229  DWORD pathSize = MAX_PATH*sizeof(WCHAR);
230  int i;
231  WCHAR key[6];
233  HMENU hMenu = GetMenu(hMainWnd);
234 
235  mi.cbSize = sizeof(MENUITEMINFOW);
236  mi.fMask = MIIM_ID | MIIM_DATA | MIIM_STRING | MIIM_FTYPE;
237  mi.fType = MFT_STRING;
238  mi.dwTypeData = itemText;
239  mi.wID = ID_FILE_RECENT1;
240 
242  for(i = 0; i < FILELIST_ENTRIES; i++)
243  {
244  wsprintfW(key, var_file, i+1);
246  if(RegQueryValueExW(hFileKey, (LPWSTR)key, 0, NULL, (LPBYTE)pFile[i], &pathSize)
247  != ERROR_SUCCESS)
248  break;
249 
250  mi.dwItemData = (ULONG_PTR)pFile[i];
251  wsprintfW(itemText, numFormat, i+1);
252 
253  lstrcpyW(buffer, pFile[i]);
254 
255  format_filelist_filename(buffer, itemText);
256 
258  mi.wID++;
259  pathSize = MAX_PATH*sizeof(WCHAR);
260  }
261  mi.fType = MFT_SEPARATOR;
262  mi.fMask = MIIM_FTYPE | MIIM_ID;
264 
265  RegCloseKey(hFileKey);
266  }
267 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ID_FILE_RECENT1
Definition: wordpad.h:33
#define MFT_STRING
Definition: winuser.h:741
#define MIIM_FTYPE
Definition: winuser.h:724
#define MF_BYCOMMAND
Definition: winuser.h:202
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR key_recentfiles[]
Definition: registry.c:29
GLuint buffer
Definition: glext.h:5915
static MONITORINFO mi
Definition: win.c:7331
static void format_filelist_filename(LPWSTR file, LPWSTR out)
Definition: registry.c:150
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ID_FILE_EXIT
Definition: resource.h:47
smooth NULL
Definition: ftsmooth.c:416
#define MIIM_ID
Definition: winuser.h:717
#define FILELIST_ENTRIES
Definition: wordpad.h:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ID_FILE_RECENT_SEPARATOR
Definition: wordpad.h:37
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MFT_SEPARATOR
Definition: winuser.h:739
HWND hMainWnd
Definition: magnifier.c:34
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
Definition: registry.c:42
LONG WINAPI RegQueryValueExW(IN HKEY hKey, IN LPCWSTR lpValueName, IN PULONG lpReserved, OUT PULONG lpType OPTIONAL, OUT PUCHAR lpData OPTIONAL, IN OUT PULONG lpcbData OPTIONAL)
Definition: registry.c:862
#define MIIM_STRING
Definition: winuser.h:722
#define lstrcpyW
Definition: compat.h:406
static const WCHAR var_file[]
Definition: registry.c:36
DWORD cbSize
Definition: winuser.h:3726
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
#define ULONG_PTR
Definition: config.h:101
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define MIIM_DATA
Definition: winuser.h:721
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
struct tagMENUITEMINFOW MENUITEMINFOW
Definition: path.c:42

Referenced by OnCreate(), preview_exit(), and registry_set_filelist().

◆ registry_read_formatopts()

static void registry_read_formatopts ( int  index,
LPCWSTR  key,
DWORD  barState[],
DWORD  wordWrap[] 
)
static

Definition at line 355 of file registry.c.

356 {
357  HKEY hKey;
358  DWORD action = 0;
359  BOOL fetched = FALSE;
360  barState[index] = 0;
361  wordWrap[index] = 0;
362 
364  return;
365 
367  {
368  DWORD size = sizeof(DWORD);
369 
371  &size) == ERROR_SUCCESS)
372  fetched = TRUE;
373  }
374 
375  if(!fetched)
376  barState[index] = (1 << BANDID_TOOLBAR) | (1 << BANDID_FORMATBAR) | (1 << BANDID_RULER) | (1 << BANDID_STATUSBAR);
377 
378  fetched = FALSE;
380  {
381  DWORD size = sizeof(DWORD);
383  &size) == ERROR_SUCCESS)
384  fetched = TRUE;
385  }
386 
387  if (!fetched)
388  {
391  else if(index == reg_formatindex(SF_TEXT))
393  }
394 
395  RegCloseKey(hKey);
396 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define TRUE
Definition: types.h:120
static DWORD
Definition: registry.c:44
#define ID_WORDWRAP_NONE
Definition: wordpad.h:110
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SF_RTF
Definition: richedit.h:721
#define ID_WORDWRAP_WINDOW
Definition: wordpad.h:111
static DWORD wordWrap[2]
Definition: wordpad.c:66
#define BANDID_STATUSBAR
Definition: wordpad.h:97
static DWORD barState[2]
Definition: wordpad.c:67
#define BANDID_TOOLBAR
Definition: wordpad.h:94
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
#define BANDID_FORMATBAR
Definition: wordpad.h:95
static const WCHAR var_barstate0[]
Definition: registry.c:38
#define BANDID_RULER
Definition: wordpad.h:96
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define SF_TEXT
Definition: richedit.h:720
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define index(s, c)
Definition: various.h:29
static const WCHAR var_wrap[]
Definition: registry.c:39
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
Definition: registry.c:42
LONG WINAPI RegQueryValueExW(IN HKEY hKey, IN LPCWSTR lpValueName, IN PULONG lpReserved, OUT PULONG lpType OPTIONAL, OUT PUCHAR lpData OPTIONAL, IN OUT PULONG lpcbData OPTIONAL)
Definition: registry.c:862
const WCHAR * action
Definition: action.c:7783
Definition: path.c:42
int reg_formatindex(WPARAM format)
Definition: registry.c:330

Referenced by registry_read_formatopts_all().

◆ registry_read_formatopts_all()

void registry_read_formatopts_all ( DWORD  barState[],
DWORD  wordWrap[] 
)

Definition at line 398 of file registry.c.

399 {
402 }
#define SF_RTF
Definition: richedit.h:721
static DWORD wordWrap[2]
Definition: wordpad.c:66
static DWORD barState[2]
Definition: wordpad.c:67
static const WCHAR key_rtf[]
Definition: registry.c:33
#define SF_TEXT
Definition: richedit.h:720
static void registry_read_formatopts(int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[])
Definition: registry.c:355
static const WCHAR key_text[]
Definition: registry.c:34
int reg_formatindex(WPARAM format)
Definition: registry.c:330

Referenced by OnCreate().

◆ registry_read_maximized()

void registry_read_maximized ( DWORD bMaximized)

Definition at line 124 of file registry.c.

125 {
126  HKEY hKey = 0;
127  DWORD size = sizeof(DWORD);
128 
129  if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS ||
130  RegQueryValueExW(hKey, var_maximized, 0, NULL, (LPBYTE)bMaximized, &size) !=
131  ERROR_SUCCESS || size != sizeof(DWORD))
132  {
133  *bMaximized = FALSE;
134  }
135 
136  RegCloseKey(hKey);
137 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
static DWORD
Definition: registry.c:44
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR key_options[]
Definition: registry.c:31
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR var_maximized[]
Definition: registry.c:40
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
Definition: registry.c:42
LONG WINAPI RegQueryValueExW(IN HKEY hKey, IN LPCWSTR lpValueName, IN PULONG lpReserved, OUT PULONG lpType OPTIONAL, OUT PUCHAR lpData OPTIONAL, IN OUT PULONG lpcbData OPTIONAL)
Definition: registry.c:862

Referenced by WinMain().

◆ registry_read_options()

void registry_read_options ( void  )

Definition at line 335 of file registry.c.

336 {
337  HKEY hKey;
338 
341  else
342  {
344  RegCloseKey(hKey);
345  }
346 
349  } else {
351  RegCloseKey(hKey);
352  }
353 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR key_options[]
Definition: registry.c:31
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR key_settings[]
Definition: registry.c:32
void registry_read_previewpages(HKEY hKey)
Definition: print.c:105
void registry_read_pagemargins(HKEY hKey)
Definition: print.c:90
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
Definition: registry.c:42

Referenced by OnCreate().

◆ registry_read_winrect()

void registry_read_winrect ( RECT rc)

Definition at line 111 of file registry.c.

112 {
113  HKEY hKey = 0;
114  DWORD size = sizeof(RECT);
115 
116  if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS ||
117  RegQueryValueExW(hKey, var_framerect, 0, NULL, (LPBYTE)rc, &size) !=
118  ERROR_SUCCESS || size != sizeof(RECT))
119  SetRect(rc, 0, 0, 600, 300);
120 
121  RegCloseKey(hKey);
122 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR key_options[]
Definition: registry.c:31
struct tagRECT RECT
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
static const WCHAR var_framerect[]
Definition: registry.c:37
unsigned long DWORD
Definition: ntddk_ex.h:95
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
Definition: registry.c:42
LONG WINAPI RegQueryValueExW(IN HKEY hKey, IN LPCWSTR lpValueName, IN PULONG lpReserved, OUT PULONG lpType OPTIONAL, OUT PUCHAR lpData OPTIONAL, IN OUT PULONG lpcbData OPTIONAL)
Definition: registry.c:862
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by WinMain().

◆ registry_set_filelist()

void registry_set_filelist ( LPCWSTR  newFile,
HWND  hMainWnd 
)

Definition at line 269 of file registry.c.

270 {
271  HKEY hKey;
272  DWORD action;
273 
275  {
276  LPCWSTR pFiles[FILELIST_ENTRIES];
277  int i;
278  HMENU hMenu = GetMenu(hMainWnd);
280  WCHAR buffer[6];
281 
282  mi.cbSize = sizeof(MENUITEMINFOW);
283  mi.fMask = MIIM_DATA;
284 
285  for(i = 0; i < FILELIST_ENTRIES; i++)
286  pFiles[i] = NULL;
287 
288  for(i = 0; GetMenuItemInfoW(hMenu, ID_FILE_RECENT1+i, FALSE, &mi); i++)
289  pFiles[i] = (LPWSTR)mi.dwItemData;
290 
291  if(lstrcmpiW(newFile, pFiles[0]))
292  {
293  for(i = 0; i < FILELIST_ENTRIES && pFiles[i]; i++)
294  {
295  if(!lstrcmpiW(pFiles[i], newFile))
296  {
297  int j;
298  for(j = 0; j < i; j++)
299  {
300  pFiles[i-j] = pFiles[i-j-1];
301  }
302  pFiles[0] = NULL;
303  break;
304  }
305  }
306 
307  if(!pFiles[0])
308  {
309  pFiles[0] = newFile;
310  } else
311  {
312  for(i = 0; i < FILELIST_ENTRIES-1; i++)
313  pFiles[FILELIST_ENTRIES-1-i] = pFiles[FILELIST_ENTRIES-2-i];
314 
315  pFiles[0] = newFile;
316  }
317 
318  for(i = 0; i < FILELIST_ENTRIES && pFiles[i]; i++)
319  {
320  wsprintfW(buffer, var_file, i+1);
321  RegSetValueExW(hKey, (LPWSTR)&buffer, 0, REG_SZ, (const BYTE*)pFiles[i],
322  (lstrlenW(pFiles[i])+1)*sizeof(WCHAR));
323  }
324  }
325  RegCloseKey(hKey);
326  }
328 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ID_FILE_RECENT1
Definition: wordpad.h:33
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static const WCHAR key_recentfiles[]
Definition: registry.c:29
GLuint buffer
Definition: glext.h:5915
static MONITORINFO mi
Definition: win.c:7331
#define lstrlenW
Definition: compat.h:407
LONG WINAPI RegSetValueExW(IN HKEY hKey, IN LPCWSTR lpValueName OPTIONAL, IN ULONG Reserved, IN ULONG dwType, IN const UCHAR *lpData, IN ULONG cbData)
Definition: registry.c:656
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define FILELIST_ENTRIES
Definition: wordpad.h:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND hMainWnd
Definition: magnifier.c:34
unsigned char BYTE
Definition: mem.h:68
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
Definition: registry.c:42
const WCHAR * action
Definition: action.c:7783
static const WCHAR var_file[]
Definition: registry.c:36
DWORD cbSize
Definition: winuser.h:3726
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define MIIM_DATA
Definition: winuser.h:721
void registry_read_filelist(HWND hMainWnd)
Definition: registry.c:217
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
struct tagMENUITEMINFOW MENUITEMINFOW
#define REG_SZ
Definition: layer.c:22

Referenced by DoOpenFile().

◆ registry_set_formatopts()

static void registry_set_formatopts ( int  index,
LPCWSTR  key,
DWORD  barState[],
DWORD  wordWrap[] 
)
static

Definition at line 404 of file registry.c.

405 {
406  HKEY hKey;
407  DWORD action = 0;
408 
410  {
412  sizeof(DWORD));
414  sizeof(DWORD));
415  RegCloseKey(hKey);
416  }
417 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ERROR_SUCCESS
Definition: deptool.c:10
static DWORD wordWrap[2]
Definition: wordpad.c:66
static DWORD barState[2]
Definition: wordpad.c:67
LONG WINAPI RegSetValueExW(IN HKEY hKey, IN LPCWSTR lpValueName OPTIONAL, IN ULONG Reserved, IN ULONG dwType, IN const UCHAR *lpData, IN ULONG cbData)
Definition: registry.c:656
static const WCHAR var_barstate0[]
Definition: registry.c:38
unsigned char * LPBYTE
Definition: typedefs.h:52
GLuint index
Definition: glext.h:6031
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR var_wrap[]
Definition: registry.c:39
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
Definition: registry.c:42
const WCHAR * action
Definition: action.c:7783
#define REG_DWORD
Definition: sdbapi.c:596
Definition: path.c:42

Referenced by registry_set_formatopts_all().

◆ registry_set_formatopts_all()

void registry_set_formatopts_all ( DWORD  barState[],
DWORD  wordWrap[] 
)

Definition at line 419 of file registry.c.

420 {
423 }
#define SF_RTF
Definition: richedit.h:721
static DWORD wordWrap[2]
Definition: wordpad.c:66
static DWORD barState[2]
Definition: wordpad.c:67
static const WCHAR key_rtf[]
Definition: registry.c:33
#define SF_TEXT
Definition: richedit.h:720
static void registry_set_formatopts(int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[])
Definition: registry.c:404
static const WCHAR key_text[]
Definition: registry.c:34
int reg_formatindex(WPARAM format)
Definition: registry.c:330

Referenced by WndProc().

◆ registry_set_options()

void registry_set_options ( HWND  hMainWnd)

Definition at line 83 of file registry.c.

84 {
85  HKEY hKey = 0;
86  DWORD action;
87 
89  {
90  WINDOWPLACEMENT wp;
91  DWORD isMaximized;
92 
93  wp.length = sizeof(WINDOWPLACEMENT);
95  isMaximized = (wp.showCmd == SW_SHOWMAXIMIZED);
96 
98  RegSetValueExW(hKey, var_maximized, 0, REG_DWORD, (LPBYTE)&isMaximized, sizeof(DWORD));
99 
101  RegCloseKey(hKey);
102  }
103 
105  {
107  RegCloseKey(hKey);
108  }
109 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
struct _WINDOWPLACEMENT WINDOWPLACEMENT
#define ERROR_SUCCESS
Definition: deptool.c:10
#define REG_BINARY
Definition: nt_native.h:1496
#define SW_SHOWMAXIMIZED
Definition: winuser.h:767
static const WCHAR key_options[]
Definition: registry.c:31
LONG WINAPI RegSetValueExW(IN HKEY hKey, IN LPCWSTR lpValueName OPTIONAL, IN ULONG Reserved, IN ULONG dwType, IN const UCHAR *lpData, IN ULONG cbData)
Definition: registry.c:656
unsigned char * LPBYTE
Definition: typedefs.h:52
void registry_set_previewpages(HKEY hKey)
Definition: print.c:99
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
static const WCHAR key_settings[]
Definition: registry.c:32
static const WCHAR var_framerect[]
Definition: registry.c:37
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND hMainWnd
Definition: magnifier.c:34
static const WCHAR var_maximized[]
Definition: registry.c:40
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
Definition: registry.c:42
const WCHAR * action
Definition: action.c:7783
RECT rcNormalPosition
Definition: winuser.h:3237
void registry_set_pagemargins(HKEY hKey)
Definition: print.c:85
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by WndProc().

◆ truncate_path()

static void truncate_path ( LPWSTR  file,
LPWSTR  out,
LPWSTR  pos1,
LPWSTR  pos2 
)
static

Definition at line 139 of file registry.c.

140 {
141  static const WCHAR dots[] = {'.','.','.',0};
142 
143  *++pos1 = 0;
144 
145  lstrcatW(out, file);
146  lstrcatW(out, dots);
147  lstrcatW(out, pos2);
148 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
static FILE * out
Definition: regtests2xml.c:44
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
Definition: fci.c:126

Referenced by format_filelist_filename().

Variable Documentation

◆ key_options

const WCHAR key_options[] = {'O','p','t','i','o','n','s',0}
static

◆ key_recentfiles

const WCHAR key_recentfiles[]
static
Initial value:
= {'R','e','c','e','n','t',' ','f','i','l','e',
' ','l','i','s','t',0}

Definition at line 29 of file registry.c.

Referenced by registry_read_filelist(), and registry_set_filelist().

◆ key_rtf

const WCHAR key_rtf[] = {'R','T','F',0}
static

Definition at line 33 of file registry.c.

Referenced by registry_read_formatopts_all(), and registry_set_formatopts_all().

◆ key_settings

const WCHAR key_settings[] = {'S','e','t','t','i','n','g','s',0}
static

Definition at line 32 of file registry.c.

Referenced by registry_read_options(), and registry_set_options().

◆ key_text

const WCHAR key_text[] = {'T','e','x','t',0}
static

Definition at line 34 of file registry.c.

Referenced by registry_read_formatopts_all(), and registry_set_formatopts_all().

◆ var_barstate0

const WCHAR var_barstate0[] = {'B','a','r','S','t','a','t','e','0',0}
static

Definition at line 38 of file registry.c.

Referenced by registry_read_formatopts(), and registry_set_formatopts().

◆ var_file

const WCHAR var_file[] = {'F','i','l','e','%','d',0}
static

Definition at line 36 of file registry.c.

Referenced by registry_read_filelist(), and registry_set_filelist().

◆ var_framerect

const WCHAR var_framerect[] = {'F','r','a','m','e','R','e','c','t',0}
static

Definition at line 37 of file registry.c.

Referenced by registry_read_winrect(), and registry_set_options().

◆ var_maximized

const WCHAR var_maximized[] = {'M','a','x','i','m','i','z','e','d',0}
static

Definition at line 40 of file registry.c.

Referenced by registry_read_maximized(), and registry_set_options().

◆ var_wrap

const WCHAR var_wrap[] = {'W','r','a','p',0}
static

Definition at line 39 of file registry.c.

Referenced by registry_read_formatopts(), and registry_set_formatopts().