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 = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"),
26 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
28 if (success != ERROR_SUCCESS)
29 printf("CreateKey Software\\subsurface failed %ld\n", success);
32 void subsurface_set_conf(char *name, pref_type_t type, const void *value)
36 /* we simply store the value as DWORD */
37 RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, &value, 4);
40 RegSetValueEx(hkey, TEXT(name), 0, REG_SZ, value, strlen(value));
44 const void *subsurface_get_conf(char *name, pref_type_t type)
52 return get_from_registry(hkey, name) ? (void *) 1 : NULL;
56 success = RegQueryValueEx(hkey, TEXT(name), NULL, NULL,
57 (LPBYTE) string, (LPDWORD)&len );
58 if (success != ERROR_SUCCESS) {
59 /* that's what happens the first time we start - just return NULL */
65 /* we shouldn't get here */
69 void subsurface_close_conf(void)
71 if (RegFlushKey(hkey) != ERROR_SUCCESS)
72 printf("RegFlushKey failed \n");