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, (LPCTSTR)TEXT(key), NULL, NULL,
15 (LPBYTE) &value, (LPDWORD)&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, (LPCTSTR)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)
34 /* since we are using the pointer 'value' as both an actual
35 * pointer to the string setting and as a way to pass the
36 * numbers 0 and 1 to this function for booleans, one of the
37 * calls to RegSetValueEx needs to pass &value (when we want
38 * to pass the boolean value), the other one passes value (the
39 * address of the string. */
42 /* we simply store the value as DWORD */
43 RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_DWORD, (const BYTE *)&value, 4);
46 RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_SZ, (const BYTE *)value, strlen(value));
50 const void *subsurface_get_conf(char *name, pref_type_t type)
58 return get_from_registry(hkey, name) ? (void *) 1 : NULL;
62 success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL,
63 (LPBYTE) string, (LPDWORD)&len );
64 if (success != ERROR_SUCCESS) {
65 /* that's what happens the first time we start - just return NULL */
71 /* we shouldn't get here */
75 void subsurface_close_conf(void)
77 if (RegFlushKey(hkey) != ERROR_SUCCESS)
78 printf("RegFlushKey failed \n");
82 const char *subsurface_USB_name()
87 const char *subsurface_icon_name()
89 return "subsurface.ico";