2 /* implements Windows specific functions */
3 #include "display-gtk.h"
8 static int get_from_registry(HKEY hkey, const char *key)
14 success = RegQueryValueEx(hkey, TEXT(key), NULL, NULL,
15 (LPBYTE) &value, &len );
16 if (success != ERROR_SUCCESS)
17 return FALSE; /* that's what happens the first time we start */
21 void subsurface_open_conf(void)
25 success = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), 0,
26 KEY_QUERY_VALUE, &hkey);
27 if (success != ERROR_SUCCESS) {
28 success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"),
29 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
31 if (success != ERROR_SUCCESS)
32 printf("CreateKey Software\\subsurface failed %ld\n", success);
36 void subsurface_set_conf(char *name, pref_type_t type, const void *value)
40 /* we simply store the value as DWORD */
41 RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, value, 4);
44 RegSetValueEx(hkey, TEXT(name), 0, REG_SZ, value, strlen(value));
48 const void *subsurface_get_conf(char *name, pref_type_t type)
56 return get_from_registry(hkey, name) ? (void *) 1 : NULL;
60 success = RegQueryValueEx(hkey, TEXT(name), NULL, NULL,
61 (LPBYTE) string, (LPDWORD)&len );
62 if (success != ERROR_SUCCESS) {
63 /* that's what happens the first time we start - just return NULL */
69 /* we shouldn't get here */
73 void subsurface_close_conf(void)
75 if (RegFlushKey(hkey) != ERROR_SUCCESS)
76 printf("RegFlushKey failed \n");