X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=windows.c;h=b8eafb6de9338ea7228bae4e99b400a940676319;hb=d2654d4951a01efd36f4189aeb02a791f20fa94d;hp=df04aa0f2a198ffaa88731dac85a3b72b5d4b415;hpb=671f6544ac8b4a6eb68576b37344e84808511eb8;p=ext%2Fsubsurface.git diff --git a/windows.c b/windows.c index df04aa0..b8eafb6 100644 --- a/windows.c +++ b/windows.c @@ -22,15 +22,11 @@ void subsurface_open_conf(void) { LONG success; - success = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), 0, - KEY_QUERY_VALUE, &hkey); - if (success != ERROR_SUCCESS) { - success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), - 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, - NULL, &hkey, NULL); - if (success != ERROR_SUCCESS) - printf("CreateKey Software\\subsurface failed %ld\n", success); - } + success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), + 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, + NULL, &hkey, NULL); + if (success != ERROR_SUCCESS) + printf("CreateKey Software\\subsurface failed %ld\n", success); } void subsurface_set_conf(char *name, pref_type_t type, const void *value) @@ -38,7 +34,7 @@ void subsurface_set_conf(char *name, pref_type_t type, const void *value) switch (type) { case PREF_BOOL: /* we simply store the value as DWORD */ - RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, (DWORD)value, 4); + RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, &value, 4); break; case PREF_STRING: RegSetValueEx(hkey, TEXT(name), 0, REG_SZ, value, strlen(value)); @@ -47,6 +43,7 @@ void subsurface_set_conf(char *name, pref_type_t type, const void *value) const void *subsurface_get_conf(char *name, pref_type_t type) { + LONG success; char *string; int len; @@ -57,7 +54,7 @@ const void *subsurface_get_conf(char *name, pref_type_t type) string = malloc(80); len = 80; success = RegQueryValueEx(hkey, TEXT(name), NULL, NULL, - (LPBYTE) string, &len ); + (LPBYTE) string, (LPDWORD)&len ); if (success != ERROR_SUCCESS) { /* that's what happens the first time we start - just return NULL */ free(string); @@ -72,6 +69,6 @@ const void *subsurface_get_conf(char *name, pref_type_t type) void subsurface_close_conf(void) { if (RegFlushKey(hkey) != ERROR_SUCCESS) - printf("RegFlushKey failed %ld\n"); + printf("RegFlushKey failed \n"); RegCloseKey(hkey); }