X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=windows.c;h=3e40c38ef72ccc56d1f03fe6aded3d948fb37a38;hb=4b77a5def6df965cae63dec8b836e18e1e09cd58;hp=df04aa0f2a198ffaa88731dac85a3b72b5d4b415;hpb=290ce56d0181c0c7e7d6e1af3eb27d3015cffca7;p=ext%2Fsubsurface.git diff --git a/windows.c b/windows.c index df04aa0..3e40c38 100644 --- a/windows.c +++ b/windows.c @@ -11,8 +11,8 @@ static int get_from_registry(HKEY hkey, const char *key) DWORD len = 4; LONG success; - success = RegQueryValueEx(hkey, TEXT(key), NULL, NULL, - (LPBYTE) &value, &len ); + success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(key), NULL, NULL, + (LPBYTE) &value, (LPDWORD)&len ); if (success != ERROR_SUCCESS) return FALSE; /* that's what happens the first time we start */ return value; @@ -22,31 +22,34 @@ 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, (LPCTSTR)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) { + /* since we are using the pointer 'value' as both an actual + * pointer to the string setting and as a way to pass the + * numbers 0 and 1 to this function for booleans, one of the + * calls to RegSetValueEx needs to pass &value (when we want + * to pass the boolean value), the other one passes value (the + * address of the string. */ switch (type) { case PREF_BOOL: /* we simply store the value as DWORD */ - RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, (DWORD)value, 4); + RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_DWORD, (const BYTE *)&value, 4); break; case PREF_STRING: - RegSetValueEx(hkey, TEXT(name), 0, REG_SZ, value, strlen(value)); + RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_SZ, (const BYTE *)value, strlen(value)); } } const void *subsurface_get_conf(char *name, pref_type_t type) { + LONG success; char *string; int len; @@ -56,8 +59,8 @@ const void *subsurface_get_conf(char *name, pref_type_t type) case PREF_STRING: string = malloc(80); len = 80; - success = RegQueryValueEx(hkey, TEXT(name), NULL, NULL, - (LPBYTE) string, &len ); + success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL, + (LPBYTE) string, (LPDWORD)&len ); if (success != ERROR_SUCCESS) { /* that's what happens the first time we start - just return NULL */ free(string); @@ -72,6 +75,11 @@ 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); } + +const char *subsurface_USB_name() +{ + return("COM3"); +}