diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2011-11-25 19:48:53 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2011-11-25 19:48:53 -0800 |
commit | d2654d4951a01efd36f4189aeb02a791f20fa94d (patch) | |
tree | f79c0026261e0f17f6723c0d165a326e131fbdba | |
parent | a9d1f318b5d1974b882b0cebc9db291f5c0d1c62 (diff) | |
download | subsurface-d2654d4951a01efd36f4189aeb02a791f20fa94d.tar.gz |
Fix the Windows preferences support
Now that I can test Windows binaries again, the bugs were rather easy to
spot. Because of the different flow of the opening, writing and closing of
the registry key my first attempt got things wrong - we simply always
create the key with all access rights; if it exists Windows will just open
it for us. The second bug was a cut'n'paste error.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | windows.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -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, 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)); |