MCPcopy Create free account
hub / github.com/NetHack/NetHack / mswin_read_reg

Function mswin_read_reg

win/win32/mswproc.c:2409–2519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2407#define INTFKEY "Interface"
2408
2409void
2410mswin_read_reg(void)
2411{
2412 HKEY key;
2413 DWORD size;
2414 DWORD safe_buf;
2415 char keystring[MAX_PATH];
2416 int i;
2417 COLORREF default_mapcolors[CLR_MAX] = {
2418 RGB(0x55, 0x55, 0x55), /* CLR_BLACK */
2419 RGB(0xFF, 0x00, 0x00), /* CLR_RED */
2420 RGB(0x00, 0x80, 0x00), /* CLR_GREEN */
2421 RGB(0xA5, 0x2A, 0x2A), /* CLR_BROWN */
2422 RGB(0x00, 0x00, 0xFF), /* CLR_BLUE */
2423 RGB(0xFF, 0x00, 0xFF), /* CLR_MAGENTA */
2424 RGB(0x00, 0xFF, 0xFF), /* CLR_CYAN */
2425 RGB(0xC0, 0xC0, 0xC0), /* CLR_GRAY */
2426 RGB(0xFF, 0xFF, 0xFF), /* NO_COLOR */
2427 RGB(0xFF, 0xA5, 0x00), /* CLR_ORANGE */
2428 RGB(0x00, 0xFF, 0x00), /* CLR_BRIGHT_GREEN */
2429 RGB(0xFF, 0xFF, 0x00), /* CLR_YELLOW */
2430 RGB(0x00, 0xC0, 0xFF), /* CLR_BRIGHT_BLUE */
2431 RGB(0xFF, 0x80, 0xFF), /* CLR_BRIGHT_MAGENTA */
2432 RGB(0x80, 0xFF, 0xFF), /* CLR_BRIGHT_CYAN */
2433 RGB(0xFF, 0xFF, 0xFF) /* CLR_WHITE */
2434 };
2435
2436 sprintf(keystring, "%s\\%s\\%s\\%s", CATEGORYKEY, COMPANYKEY, PRODUCTKEY,
2437 SETTINGSKEY);
2438
2439 /* Set the defaults here. The very first time the app is started, nothing
2440 is
2441 read from the registry, so these defaults apply. */
2442 GetNHApp()->saveRegistrySettings = 1; /* Normally, we always save */
2443 GetNHApp()->regNetHackMode = TRUE;
2444
2445 for (i = 0; i < CLR_MAX; i++)
2446 GetNHApp()->regMapColors[i] = default_mapcolors[i];
2447
2448 if (RegOpenKeyEx(HKEY_CURRENT_USER, keystring, 0, KEY_READ, &key)
2449 != ERROR_SUCCESS)
2450 return;
2451
2452 size = sizeof(DWORD);
2453
2454#define NHGETREG_DWORD(name, val) \
2455 RegQueryValueEx(key, (name), 0, NULL, (unsigned char *)(&safe_buf), \
2456 &size); \
2457 (val) = safe_buf;
2458
2459 /* read the keys here */
2460 NHGETREG_DWORD(INTFKEY, GetNHApp()->regNetHackMode);
2461
2462 /* read window placement */
2463 NHGETREG_DWORD(MAINSHOWSTATEKEY, GetNHApp()->regMainShowState);
2464 NHGETREG_DWORD(MAINMINXKEY, GetNHApp()->regMainMinX);
2465 NHGETREG_DWORD(MAINMINYKEY, GetNHApp()->regMainMinY);
2466 NHGETREG_DWORD(MAINMAXXKEY, GetNHApp()->regMainMaxX);

Callers 1

mswin_init_nhwindowsFunction · 0.70

Calls 2

GetNHAppFunction · 0.70
RGBClass · 0.50

Tested by

no test coverage detected