summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2011-10-31 03:12:51 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2011-10-31 21:18:53 -0700
commit43601f654675c8734c9ca5850cc41dac16d1989a (patch)
tree75c02e5277b5793af1695de7e0d6e28f670d9cdd /gtk-gui.c
parent904f1ad4c56b8987d2efd9f2efdd9951bf9e8eab (diff)
downloadsubsurface-43601f654675c8734c9ca5850cc41dac16d1989a.tar.gz
Using RegQueryValueEx instead of RegGetValue
Provides compatibility with winxp-32bit in gtk-gui.c, since RegGetValue is only available on the 64bit build of the OS. Fixed whitespace issues, fixed obvious typo (this patch clearly wasn't even compile tested) Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index b1bc82a73..b16050838 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -725,15 +725,14 @@ static void drag_cb(GtkWidget *widget, GdkDragContext *context,
}
#ifdef WIN32
-static int get_from_registry(const char *key)
+static int get_from_registry(HKEY hkey, const char *key)
{
DWORD value;
- DWORD type;
DWORD len = 4;
LONG success;
- success = RegGetValue(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), TEXT(key),
- RRF_RT_ANY, &type, &value, &len);
+ success = RegQueryValueEx(hkey, TEXT(key), NULL, NULL,
+ (LPBYTE) &value, &len );
if (success != ERROR_SUCCESS)
return FALSE; /* that's what happens the first time we start */
return value;
@@ -782,29 +781,34 @@ void init_ui(int argc, char **argv)
divelist_font = gconf_client_get_string(gconf, GCONF_NAME(divelist_font), NULL);
#else
- DWORD type;
DWORD len = 4;
LONG success;
+ HKEY hkey;
- output_units.length = get_from_registry("feet");
- output_units.pressure = get_from_registry("psi");
- output_units.volume = get_from_registry("cuft");
- output_units.temperature = get_from_registry("fahrenheit");
- visible_cols.temperature = get_from_registry("temperature");
- visible_cols.cylinder = get_from_registry("cylinder");
- visible_cols.nitrox = get_from_registry("nitrox");
- visible_cols.sac = get_from_registry("sac");
- visible_cols.otu = get_from_registry("otu");
+ success = RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("Software\\subsurface"), 0,
+ KEY_QUERY_VALUE, &hkey);
+
+ output_units.length = get_from_registry(hkey, "feet");
+ output_units.pressure = get_from_registry(hkey, "psi");
+ output_units.volume = get_from_registry(hkey, "cuft");
+ output_units.temperature = get_from_registry(hkey, "fahrenheit");
+ visible_cols.temperature = get_from_registry(hkey, "temperature");
+ visible_cols.cylinder = get_from_registry(hkey, "cylinder");
+ visible_cols.nitrox = get_from_registry(hkey, "nitrox");
+ visible_cols.sac = get_from_registry(hkey, "sac");
+ visible_cols.otu = get_from_registry(hkey, "otu");
divelist_font = malloc(80);
len = 80;
- success = RegGetValue(HKEY_CURRENT_USER, TEXT("Software\\subsurface"),
- TEXT("divelist_font"), RRF_RT_ANY, &type, divelist_font, &len);
+ success = RegQueryValueEx(hkey, TEXT("divelist_font"), NULL, NULL,
+ (LPBYTE) divelist_font, &len );
if (success != ERROR_SUCCESS) {
/* that's what happens the first time we start - just use the default */
free(divelist_font);
divelist_font = NULL;
}
+ RegCloseKey(hkey);
+
#endif
if (!divelist_font)
divelist_font = DIVELIST_DEFAULT_FONT;