mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Add more typecasts for Windows`
This is based on an older patch by Lubomir I. Ivanov <neolit123@gmail.com> which no longer applies due to the refactoring of the registry setting code. It takes care of all of the casts between actual C types and the Windows specific types that the Windows API functions expect. It also adds some comments to the overloading of "value" in our subsurface_set_conf function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d2654d4951
commit
192713680e
1 changed files with 12 additions and 6 deletions
18
windows.c
18
windows.c
|
@ -11,8 +11,8 @@ static int get_from_registry(HKEY hkey, const char *key)
|
|||
DWORD len = 4;
|
||||
LONG success;
|
||||
|
||||
success = RegQueryValueEx(hkey, TEXT(key), NULL, NULL,
|
||||
(LPBYTE) &value, &len );
|
||||
success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(key), NULL, NULL,
|
||||
(LPBYTE) &value, (LPDWORD)&len );
|
||||
if (success != ERROR_SUCCESS)
|
||||
return FALSE; /* that's what happens the first time we start */
|
||||
return value;
|
||||
|
@ -22,7 +22,7 @@ void subsurface_open_conf(void)
|
|||
{
|
||||
LONG success;
|
||||
|
||||
success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"),
|
||||
success = RegCreateKeyEx(HKEY_CURRENT_USER, (LPCTSTR)TEXT("Software\\subsurface"),
|
||||
0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
|
||||
NULL, &hkey, NULL);
|
||||
if (success != ERROR_SUCCESS)
|
||||
|
@ -31,13 +31,19 @@ void subsurface_open_conf(void)
|
|||
|
||||
void subsurface_set_conf(char *name, pref_type_t type, const void *value)
|
||||
{
|
||||
/* since we are using the pointer 'value' as both an actual
|
||||
* pointer to the string setting and as a way to pass the
|
||||
* numbers 0 and 1 to this function for booleans, one of the
|
||||
* calls to RegSetValueEx needs to pass &value (when we want
|
||||
* to pass the boolean value), the other one passes value (the
|
||||
* address of the string. */
|
||||
switch (type) {
|
||||
case PREF_BOOL:
|
||||
/* we simply store the value as DWORD */
|
||||
RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, &value, 4);
|
||||
RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_DWORD, (const BYTE *)&value, 4);
|
||||
break;
|
||||
case PREF_STRING:
|
||||
RegSetValueEx(hkey, TEXT(name), 0, REG_SZ, value, strlen(value));
|
||||
RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_SZ, (const BYTE *)value, strlen(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +59,7 @@ const void *subsurface_get_conf(char *name, pref_type_t type)
|
|||
case PREF_STRING:
|
||||
string = malloc(80);
|
||||
len = 80;
|
||||
success = RegQueryValueEx(hkey, TEXT(name), NULL, NULL,
|
||||
success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL,
|
||||
(LPBYTE) string, (LPDWORD)&len );
|
||||
if (success != ERROR_SUCCESS) {
|
||||
/* that's what happens the first time we start - just return NULL */
|
||||
|
|
Loading…
Reference in a new issue