ReactOS  0.4.13-dev-563-g0561610
settings.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _CONSOLE_STATE_INFO
 

Macros

#define WM_SETCONSOLEINFO   (WM_USER + 201)
 
#define RGBFromAttrib(Console, Attribute)   ((Console)->Colors[(Attribute) & 0xF])
 
#define TextAttribFromAttrib(Attribute)   ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? (Attribute) & 0xF : ((Attribute) >> 4) & 0xF )
 
#define BkgdAttribFromAttrib(Attribute)   ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? ((Attribute) >> 4) & 0xF : (Attribute) & 0xF )
 
#define MakeAttrib(TextAttrib, BkgdAttrib)   (USHORT)((((BkgdAttrib) & 0xF) << 4) | ((TextAttrib) & 0xF))
 

Typedefs

typedef struct _CONSOLE_STATE_INFO CONSOLE_STATE_INFO
 
typedef struct _CONSOLE_STATE_INFOPCONSOLE_STATE_INFO
 

Functions

BOOLEAN ConCfgOpenUserSettings (IN LPCWSTR ConsoleTitle, OUT PHKEY phSubKey, IN REGSAM samDesired, IN BOOLEAN Create)
 
BOOLEAN ConCfgReadUserSettings (IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN BOOLEAN DefaultSettings)
 
BOOLEAN ConCfgWriteUserSettings (IN PCONSOLE_STATE_INFO ConsoleInfo, IN BOOLEAN DefaultSettings)
 
VOID ConCfgInitDefaultSettings (IN OUT PCONSOLE_STATE_INFO ConsoleInfo)
 
VOID ConCfgGetDefaultSettings (IN OUT PCONSOLE_STATE_INFO ConsoleInfo)
 

Macro Definition Documentation

◆ BkgdAttribFromAttrib

#define BkgdAttribFromAttrib (   Attribute)    ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? ((Attribute) >> 4) & 0xF : (Attribute) & 0xF )

Definition at line 73 of file settings.h.

◆ MakeAttrib

#define MakeAttrib (   TextAttrib,
  BkgdAttrib 
)    (USHORT)((((BkgdAttrib) & 0xF) << 4) | ((TextAttrib) & 0xF))

Definition at line 74 of file settings.h.

◆ RGBFromAttrib

#define RGBFromAttrib (   Console,
  Attribute 
)    ((Console)->Colors[(Attribute) & 0xF])

Definition at line 71 of file settings.h.

◆ TextAttribFromAttrib

#define TextAttribFromAttrib (   Attribute)    ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? (Attribute) & 0xF : ((Attribute) >> 4) & 0xF )

Definition at line 72 of file settings.h.

◆ WM_SETCONSOLEINFO

#define WM_SETCONSOLEINFO   (WM_USER + 201)

Definition at line 21 of file settings.h.

Typedef Documentation

◆ CONSOLE_STATE_INFO

◆ PCONSOLE_STATE_INFO

Function Documentation

◆ ConCfgGetDefaultSettings()

VOID ConCfgGetDefaultSettings ( IN OUT PCONSOLE_STATE_INFO  ConsoleInfo)

Definition at line 491 of file settings.c.

493 {
494  if (ConsoleInfo == NULL) return;
495 
496  /*
497  * 1. Load the default values
498  */
500 
501  /*
502  * 2. Overwrite them with the ones stored in HKCU\Console.
503  * If the HKCU\Console key doesn't exist, create it
504  * and store the default values inside.
505  */
508 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN ConCfgWriteUserSettings(IN PCONSOLE_STATE_INFO ConsoleInfo, IN BOOLEAN DefaultSettings)
Definition: settings.c:344
BOOLEAN ConCfgReadUserSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN BOOLEAN DefaultSettings)
Definition: settings.c:167
VOID ConCfgInitDefaultSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo)
Definition: settings.c:436
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47

Referenced by ConSrvInitConsole(), and InitDefaultConsoleInfo().

◆ ConCfgInitDefaultSettings()

VOID ConCfgInitDefaultSettings ( IN OUT PCONSOLE_STATE_INFO  ConsoleInfo)

HKCU,"Console","LoadConIme",0x00010003,1

Definition at line 436 of file settings.c.

438 {
439  if (ConsoleInfo == NULL) return;
440 
441  // ASSERT(ConsoleInfo->cbSize >= sizeof(CONSOLE_STATE_INFO));
442 
444 
445  // wcsncpy(ConsoleInfo->FaceName, L"DejaVu Sans Mono", LF_FACESIZE);
446  // ConsoleInfo->FontSize = MAKELONG(8, 12); // 0x000C0008; // font is 8x12
447 
448  StringCchCopyW(ConsoleInfo->FaceName, ARRAYSIZE(ConsoleInfo->FaceName), L"VGA"); // HACK: !!
449  // ConsoleInfo->FaceName[0] = UNICODE_NULL;
450  // ConsoleInfo->FontSize.X = 8;
451  // ConsoleInfo->FontSize.Y = 12;
452  ConsoleInfo->FontSize.X = 0; // HACK: !!
453  ConsoleInfo->FontSize.Y = 16; // HACK: !!
454  ConsoleInfo->FontFamily = FF_DONTCARE;
455  ConsoleInfo->FontWeight = FW_NORMAL; // FW_DONTCARE;
456 
457  /* Initialize the default properties */
458 
459 // #define DEFAULT_HISTORY_COMMANDS_NUMBER 50
460 // #define DEFAULT_HISTORY_BUFFERS_NUMBER 4
461  ConsoleInfo->HistoryBufferSize = 50;
462  ConsoleInfo->NumberOfHistoryBuffers = 4;
463  ConsoleInfo->HistoryNoDup = FALSE;
464 
465  ConsoleInfo->QuickEdit = FALSE;
466  ConsoleInfo->InsertMode = TRUE;
467  // ConsoleInfo->InputBufferSize = 0;
468 
469  // Rule: ScreenBufferSize >= WindowSize
470  ConsoleInfo->ScreenBufferSize.X = 80;
471  ConsoleInfo->ScreenBufferSize.Y = 300;
472  ConsoleInfo->WindowSize.X = 80;
473  ConsoleInfo->WindowSize.Y = 25;
474 
475  ConsoleInfo->FullScreen = FALSE;
476  ConsoleInfo->AutoPosition = TRUE;
477  ConsoleInfo->WindowPosition.x = 0;
478  ConsoleInfo->WindowPosition.y = 0;
479 
480  ConsoleInfo->CursorSize = CSR_DEFAULT_CURSOR_SIZE;
481 
482  ConsoleInfo->ScreenAttributes = DEFAULT_SCREEN_ATTRIB;
483  ConsoleInfo->PopupAttributes = DEFAULT_POPUP_ATTRIB;
484 
485  RtlCopyMemory(ConsoleInfo->ColorTable, s_Colors, sizeof(s_Colors));
486 
487  ConsoleInfo->CodePage = GetOEMCP();
488 }
#define DEFAULT_SCREEN_ATTRIB
Definition: settings.c:29
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define FF_DONTCARE
Definition: wingdi.h:447
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static const COLORREF s_Colors[16]
Definition: settings.c:37
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
#define CSR_DEFAULT_CURSOR_SIZE
Definition: settings.c:26
static const WCHAR L[]
Definition: oid.c:1250
#define DEFAULT_POPUP_ATTRIB
Definition: settings.c:30
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define FW_NORMAL
Definition: wingdi.h:372
UINT WINAPI GetOEMCP(VOID)
Definition: nls.c:2184

Referenced by ConCfgGetDefaultSettings().

◆ ConCfgOpenUserSettings()

BOOLEAN ConCfgOpenUserSettings ( IN LPCWSTR  ConsoleTitle,
OUT PHKEY  phSubKey,
IN REGSAM  samDesired,
IN BOOLEAN  Create 
)

Definition at line 93 of file settings.c.

98 {
101  WCHAR szBuffer[MAX_PATH] = L"Console\\";
102  WCHAR szBuffer2[MAX_PATH] = L"";
103  HKEY hKey; // CurrentUserKeyHandle
104 
105  /*
106  * Console properties are stored under the HKCU\Console\* key.
107  *
108  * We use the original console title as the subkey name for storing
109  * console properties. We need to distinguish whether we were launched
110  * via the console application directly or via a shortcut.
111  *
112  * If the title of the console corresponds to a path (more precisely,
113  * if the title is of the form: C:\ReactOS<some_path><some_app.exe>),
114  * then use the corresponding unexpanded path and with the backslashes
115  * replaced by underscores, to make the registry happy,
116  * i.e. %SystemRoot%_<some_path>_<some_app.exe>
117  */
118 
119  /* Open the per-user registry key where the console properties are saved */
120  Status = RtlOpenCurrentUser(/*samDesired*/MAXIMUM_ALLOWED, (PHANDLE)&/*CurrentUserKeyHandle*/hKey);
121  if (!NT_SUCCESS(Status))
122  {
123  DPRINT1("RtlOpenCurrentUser() failed, Status = 0x%08lx\n", Status);
125  return FALSE;
126  }
127 
128  /*
129  * Try to open properties via the console title:
130  * to make the registry happy, replace all the
131  * backslashes by underscores.
132  */
133  TranslateConsoleName(szBuffer2, ConsoleTitle, ARRAYSIZE(szBuffer2));
134 
135  /* Create the registry path */
136  StringCchCatW(szBuffer, MAX_PATH - wcslen(szBuffer) - 1, szBuffer2);
137 
138  /* Create or open the registry key */
139  if (Create)
140  {
141  /* Create the key */
142  Success = (RegCreateKeyExW(hKey,
143  szBuffer,
144  0, NULL,
146  samDesired,
147  NULL,
148  phSubKey,
149  NULL) == ERROR_SUCCESS);
150  }
151  else
152  {
153  /* Open the key */
154  Success = (RegOpenKeyExW(hKey,
155  szBuffer,
156  0,
157  samDesired,
158  phSubKey) == ERROR_SUCCESS);
159  }
160 
161  /* Close the parent key and return success or not */
162  NtClose(hKey);
163  return Success;
164 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
_In_ BOOLEAN Create
Definition: pstypes.h:511
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
NTSYSAPI NTSTATUS NTAPI RtlOpenCurrentUser(_In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE KeyHandle)
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
static VOID TranslateConsoleName(OUT LPWSTR DestString, IN LPCWSTR ConsoleName, IN UINT MaxStrLen)
Definition: settings.c:62
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by ConCfgReadUserSettings(), and ConCfgWriteUserSettings().

◆ ConCfgReadUserSettings()

BOOLEAN ConCfgReadUserSettings ( IN OUT PCONSOLE_STATE_INFO  ConsoleInfo,
IN BOOLEAN  DefaultSettings 
)

Definition at line 167 of file settings.c.

170 {
172  HKEY hKey;
173  DWORD dwNumValues = 0;
174  DWORD dwIndex;
175  DWORD dwColorIndex = 0;
176  DWORD dwType;
177  WCHAR szValueName[MAX_PATH];
178  DWORD dwValueName;
179  WCHAR szValue[LF_FACESIZE] = L"";
180  DWORD Value;
181  DWORD dwValue;
182 
183  if (!ConCfgOpenUserSettings(DefaultSettings ? L"" : ConsoleInfo->ConsoleTitle,
184  &hKey, KEY_READ, FALSE))
185  {
186  DPRINT("ConCfgOpenUserSettings() failed\n");
187  return FALSE;
188  }
189 
190  if (RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
191  &dwNumValues, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
192  {
193  DPRINT("ConCfgReadUserSettings: RegQueryInfoKeyW() failed\n");
194  RegCloseKey(hKey);
195  return FALSE;
196  }
197 
198  DPRINT("ConCfgReadUserSettings() entered, dwNumValues %d\n", dwNumValues);
199 
200  for (dwIndex = 0; dwIndex < dwNumValues; dwIndex++)
201  {
202  dwValue = sizeof(Value);
203  dwValueName = ARRAYSIZE(szValueName);
204 
205  if (RegEnumValueW(hKey, dwIndex, szValueName, &dwValueName, NULL, &dwType, (BYTE*)&Value, &dwValue) != ERROR_SUCCESS)
206  {
207  if (dwType == REG_SZ)
208  {
209  /*
210  * Retry in case of string value
211  */
212  dwValue = sizeof(szValue);
213  dwValueName = ARRAYSIZE(szValueName);
214  if (RegEnumValueW(hKey, dwIndex, szValueName, &dwValueName, NULL, NULL, (BYTE*)szValue, &dwValue) != ERROR_SUCCESS)
215  break;
216  }
217  else
218  {
219  break;
220  }
221  }
222 
223  if (!wcsncmp(szValueName, L"ColorTable", wcslen(L"ColorTable")))
224  {
225  dwColorIndex = 0;
226  swscanf(szValueName, L"ColorTable%2d", &dwColorIndex);
227  if (dwColorIndex < ARRAYSIZE(ConsoleInfo->ColorTable))
228  {
229  ConsoleInfo->ColorTable[dwColorIndex] = Value;
230  Success = TRUE;
231  }
232  }
233  if (!wcscmp(szValueName, L"CodePage"))
234  {
235  if (IsValidCodePage(Value))
236  ConsoleInfo->CodePage = Value;
237  Success = TRUE;
238  }
239  else if (!wcscmp(szValueName, L"FaceName"))
240  {
241  /* A NULL value means that the defaults should be used instead */
242  if (*szValue)
243  {
244  StringCchCopyNW(ConsoleInfo->FaceName, ARRAYSIZE(ConsoleInfo->FaceName),
245  szValue, ARRAYSIZE(szValue));
246  }
247  Success = TRUE;
248  }
249  else if (!wcscmp(szValueName, L"FontFamily"))
250  {
251  /* A zero value means that the defaults should be used instead */
252  if (Value)
253  ConsoleInfo->FontFamily = Value;
254  Success = TRUE;
255  }
256  else if (!wcscmp(szValueName, L"FontSize"))
257  {
258  /* A zero value means that the defaults should be used instead */
259  if (Value)
260  {
261  ConsoleInfo->FontSize.X = LOWORD(Value); // Width
262  ConsoleInfo->FontSize.Y = HIWORD(Value); // Height
263  }
264  Success = TRUE;
265  }
266  else if (!wcscmp(szValueName, L"FontWeight"))
267  {
268  /* A zero value means that the defaults should be used instead */
269  if (Value)
270  ConsoleInfo->FontWeight = Value;
271  Success = TRUE;
272  }
273  else if (!wcscmp(szValueName, L"HistoryBufferSize"))
274  {
275  ConsoleInfo->HistoryBufferSize = Value;
276  Success = TRUE;
277  }
278  else if (!wcscmp(szValueName, L"NumberOfHistoryBuffers"))
279  {
280  ConsoleInfo->NumberOfHistoryBuffers = Value;
281  Success = TRUE;
282  }
283  else if (!wcscmp(szValueName, L"HistoryNoDup"))
284  {
285  ConsoleInfo->HistoryNoDup = !!Value;
286  Success = TRUE;
287  }
288  else if (!wcscmp(szValueName, L"QuickEdit"))
289  {
290  ConsoleInfo->QuickEdit = !!Value;
291  Success = TRUE;
292  }
293  else if (!wcscmp(szValueName, L"InsertMode"))
294  {
295  ConsoleInfo->InsertMode = !!Value;
296  Success = TRUE;
297  }
298  else if (!wcscmp(szValueName, L"ScreenBufferSize"))
299  {
300  ConsoleInfo->ScreenBufferSize.X = LOWORD(Value);
301  ConsoleInfo->ScreenBufferSize.Y = HIWORD(Value);
302  Success = TRUE;
303  }
304  else if (!wcscmp(szValueName, L"FullScreen"))
305  {
306  ConsoleInfo->FullScreen = Value;
307  Success = TRUE;
308  }
309  else if (!wcscmp(szValueName, L"WindowPosition"))
310  {
311  ConsoleInfo->AutoPosition = FALSE;
312  ConsoleInfo->WindowPosition.x = LOWORD(Value);
313  ConsoleInfo->WindowPosition.y = HIWORD(Value);
314  Success = TRUE;
315  }
316  else if (!wcscmp(szValueName, L"WindowSize"))
317  {
318  ConsoleInfo->WindowSize.X = LOWORD(Value);
319  ConsoleInfo->WindowSize.Y = HIWORD(Value);
320  Success = TRUE;
321  }
322  else if (!wcscmp(szValueName, L"CursorSize"))
323  {
324  ConsoleInfo->CursorSize = min(max(Value, 0), 100);
325  Success = TRUE;
326  }
327  else if (!wcscmp(szValueName, L"ScreenColors"))
328  {
329  ConsoleInfo->ScreenAttributes = (USHORT)Value;
330  Success = TRUE;
331  }
332  else if (!wcscmp(szValueName, L"PopupColors"))
333  {
334  ConsoleInfo->PopupAttributes = (USHORT)Value;
335  Success = TRUE;
336  }
337  }
338 
339  RegCloseKey(hKey);
340  return Success;
341 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define max(a, b)
Definition: svc.c:63
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
#define TRUE
Definition: types.h:120
#define LF_FACESIZE
Definition: dimm.idl:39
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
BOOLEAN ConCfgOpenUserSettings(IN LPCWSTR ConsoleTitle, OUT PHKEY phSubKey, IN REGSAM samDesired, IN BOOLEAN Create)
Definition: settings.c:93
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char BOOLEAN
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2853
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3686
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL WINAPI IsValidCodePage(UINT CodePage)
Definition: nls.c:1468
unsigned short USHORT
Definition: pedump.c:61
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define min(a, b)
Definition: monoChain.cc:55
#define HIWORD(l)
Definition: typedefs.h:246
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22

Referenced by ConCfgGetDefaultSettings(), and ConSrvInitConsole().

◆ ConCfgWriteUserSettings()

BOOLEAN ConCfgWriteUserSettings ( IN PCONSOLE_STATE_INFO  ConsoleInfo,
IN BOOLEAN  DefaultSettings 
)

Definition at line 344 of file settings.c.

347 {
348  HKEY hKey;
349  DWORD Storage = 0;
350 
351 #define SetConsoleSetting(SettingName, SettingType, SettingSize, Setting, DefaultValue) \
352 do { \
353  if (DefaultSettings || (!DefaultSettings && (*(Setting) != (DefaultValue)))) \
354  { \
355  RegSetValueExW(hKey, (SettingName), 0, (SettingType), (PBYTE)(Setting), (SettingSize)); \
356  } \
357  else \
358  { \
359  RegDeleteValueW(hKey, (SettingName)); \
360  } \
361 } while (0)
362 
363  WCHAR szValueName[15];
364  UINT i;
365 
366  if (!ConCfgOpenUserSettings(DefaultSettings ? L"" : ConsoleInfo->ConsoleTitle,
367  &hKey, KEY_WRITE, TRUE))
368  {
369  return FALSE;
370  }
371 
372  for (i = 0; i < ARRAYSIZE(ConsoleInfo->ColorTable); ++i)
373  {
374  /*
375  * Write only the new value if we are saving the global settings
376  * or we are saving settings for a particular console, which differs
377  * from the default ones.
378  */
379  swprintf(szValueName, L"ColorTable%02u", i);
380  SetConsoleSetting(szValueName, REG_DWORD, sizeof(DWORD), &ConsoleInfo->ColorTable[i], s_Colors[i]);
381  }
382 
383  SetConsoleSetting(L"CodePage", REG_DWORD, sizeof(DWORD), &ConsoleInfo->CodePage, CP_ACP /* CP_OEMCP */);
384  SetConsoleSetting(L"FaceName", REG_SZ, (wcslen(ConsoleInfo->FaceName) + 1) * sizeof(WCHAR), ConsoleInfo->FaceName, UNICODE_NULL); // wcsnlen
385  SetConsoleSetting(L"FontFamily", REG_DWORD, sizeof(DWORD), &ConsoleInfo->FontFamily, FF_DONTCARE);
386 
387  Storage = MAKELONG(ConsoleInfo->FontSize.X, ConsoleInfo->FontSize.Y); // Width, Height
388  SetConsoleSetting(L"FontSize", REG_DWORD, sizeof(DWORD), &Storage, 0);
389 
390  SetConsoleSetting(L"FontWeight", REG_DWORD, sizeof(DWORD), &ConsoleInfo->FontWeight, FW_DONTCARE);
391 
392  SetConsoleSetting(L"HistoryBufferSize", REG_DWORD, sizeof(DWORD), &ConsoleInfo->HistoryBufferSize, 50);
393  SetConsoleSetting(L"NumberOfHistoryBuffers", REG_DWORD, sizeof(DWORD), &ConsoleInfo->NumberOfHistoryBuffers, 4);
394 
395  Storage = ConsoleInfo->HistoryNoDup;
396  SetConsoleSetting(L"HistoryNoDup", REG_DWORD, sizeof(DWORD), &Storage, FALSE);
397 
398  Storage = ConsoleInfo->QuickEdit;
399  SetConsoleSetting(L"QuickEdit", REG_DWORD, sizeof(DWORD), &Storage, FALSE);
400 
401  Storage = ConsoleInfo->InsertMode;
402  SetConsoleSetting(L"InsertMode", REG_DWORD, sizeof(DWORD), &Storage, TRUE);
403 
404  Storage = MAKELONG(ConsoleInfo->ScreenBufferSize.X, ConsoleInfo->ScreenBufferSize.Y);
405  SetConsoleSetting(L"ScreenBufferSize", REG_DWORD, sizeof(DWORD), &Storage, MAKELONG(80, 300));
406 
407  Storage = ConsoleInfo->FullScreen;
408  SetConsoleSetting(L"FullScreen", REG_DWORD, sizeof(DWORD), &Storage, FALSE);
409 
410  if (ConsoleInfo->AutoPosition == FALSE)
411  {
412  Storage = MAKELONG(ConsoleInfo->WindowPosition.x, ConsoleInfo->WindowPosition.y);
413  RegSetValueExW(hKey, L"WindowPosition", 0, REG_DWORD, (PBYTE)&Storage, sizeof(DWORD));
414  }
415  else
416  {
417  RegDeleteValueW(hKey, L"WindowPosition");
418  }
419 
420  Storage = MAKELONG(ConsoleInfo->WindowSize.X, ConsoleInfo->WindowSize.Y);
421  SetConsoleSetting(L"WindowSize", REG_DWORD, sizeof(DWORD), &Storage, MAKELONG(80, 25));
422 
423  SetConsoleSetting(L"CursorSize", REG_DWORD, sizeof(DWORD), &ConsoleInfo->CursorSize, CSR_DEFAULT_CURSOR_SIZE);
424 
425  Storage = ConsoleInfo->ScreenAttributes;
426  SetConsoleSetting(L"ScreenColors", REG_DWORD, sizeof(DWORD), &Storage, DEFAULT_SCREEN_ATTRIB);
427 
428  Storage = ConsoleInfo->PopupAttributes;
429  SetConsoleSetting(L"PopupColors", REG_DWORD, sizeof(DWORD), &Storage, DEFAULT_POPUP_ATTRIB);
430 
431  RegCloseKey(hKey);
432  return TRUE;
433 }
#define DEFAULT_SCREEN_ATTRIB
Definition: settings.c:29
#define TRUE
Definition: types.h:120
#define FF_DONTCARE
Definition: wingdi.h:447
#define CP_ACP
Definition: compat.h:99
BOOLEAN ConCfgOpenUserSettings(IN LPCWSTR ConsoleTitle, OUT PHKEY phSubKey, IN REGSAM samDesired, IN BOOLEAN Create)
Definition: settings.c:93
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define UNICODE_NULL
static const COLORREF s_Colors[16]
Definition: settings.c:37
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CSR_DEFAULT_CURSOR_SIZE
Definition: settings.c:26
static const WCHAR L[]
Definition: oid.c:1250
#define DEFAULT_POPUP_ATTRIB
Definition: settings.c:30
#define FW_DONTCARE
Definition: wingdi.h:367
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
unsigned int UINT
Definition: ndis.h:50
#define REG_DWORD
Definition: sdbapi.c:596
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static IStorage Storage
Definition: ole2.c:3548
#define SetConsoleSetting(SettingName, SettingType, SettingSize, Setting, DefaultValue)
#define REG_SZ
Definition: layer.c:22

Referenced by ConCfgGetDefaultSettings(), and InitApplet().