3 // Returns key for HKEY_CURRENT_USER\"Software"\Company\AppName
4 // creating it if it doesn't exist
5 // responsibility of the caller to call RegCloseKey() on the returned HKEY
7 HKEY
GetAppKey (char* AppName
)
11 if (RegOpenKeyEx (HKEY_CURRENT_USER
, "Software", 0, KEY_WRITE
| KEY_READ
,
12 &hSoftKey
) == ERROR_SUCCESS
)
15 RegCreateKeyEx (hSoftKey
, AppName
, 0, REG_NONE
,
16 REG_OPTION_NON_VOLATILE
, KEY_WRITE
| KEY_READ
, NULL
,
20 RegCloseKey (hSoftKey
);
26 // HKEY_CURRENT_USER\"Software"\RegistryKey\AppName\Section
27 // creating it if it doesn't exist.
28 // responsibility of the caller to call RegCloseKey () on the returned HKEY
30 HKEY
GetSectionKey (HKEY hAppKey
, LPCTSTR Section
)
32 HKEY hSectionKey
= NULL
;
34 RegCreateKeyEx (hAppKey
, Section
, 0, REG_NONE
,
35 REG_OPTION_NON_VOLATILE
, KEY_WRITE
|KEY_READ
, NULL
,
36 &hSectionKey
, &Dummy
);
40 int GetRegistryInt (HKEY hSectionKey
, LPCTSTR Entry
, int Default
)
44 DWORD Count
= sizeof (DWORD
);
45 if (RegQueryValueEx (hSectionKey
, (LPTSTR
) Entry
, NULL
, &Type
,
46 (LPBYTE
) &Value
, &Count
) == ERROR_SUCCESS
)
51 bool WriteRegistryInt (HKEY hSectionKey
, char* Entry
, int nValue
)
53 return RegSetValueEx (hSectionKey
, Entry
, NULL
, REG_DWORD
,
54 (LPBYTE
) &nValue
, sizeof (nValue
)) == ERROR_SUCCESS
;