aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/t-w32-reg.c4
-rw-r--r--common/w32-reg.c20
-rw-r--r--common/w32help.h2
3 files changed, 20 insertions, 6 deletions
diff --git a/common/t-w32-reg.c b/common/t-w32-reg.c
index 9665003ea..1a44e385c 100644
--- a/common/t-w32-reg.c
+++ b/common/t-w32-reg.c
@@ -56,7 +56,7 @@ test_read_registry (void)
string2 = read_w32_reg_string
("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion"
- "\\Internet Settings:User Agent");
+ "\\Internet Settings:User Agent", NULL);
if (!string2)
fail (1);
fprintf (stderr, "User agent: %s\n", string2);
@@ -76,7 +76,7 @@ main (int argc, char **argv)
{
if (argc > 1)
{
- char *string = read_w32_reg_string (argv[1]);
+ char *string = read_w32_reg_string (argv[1], NULL);
printf ("%s -> %s\n", argv[1], string? string : "(null)");
xfree (string);
}
diff --git a/common/w32-reg.c b/common/w32-reg.c
index 94049a283..9af7d2d28 100644
--- a/common/w32-reg.c
+++ b/common/w32-reg.c
@@ -71,14 +71,19 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
*
* Note that the first backslash and the first colon act as delimiters.
*
- * Returns a malloced string or NULL if not found.
+ * Returns a malloced string or NULL if not found. If R_HKLM_FALLBACK
+ * is not NULL, no class was given, and the result came from HKLM,
+ * true is stored there.
*/
char *
-read_w32_reg_string (const char *key_arg)
+read_w32_reg_string (const char *key_arg, int *r_hklm_fallback)
{
char *key;
char *p1, *p2;
- char *result;
+ char *result, *result2;
+
+ if (r_hklm_fallback)
+ *r_hklm_fallback = 0;
if (!key_arg)
return NULL;
@@ -101,6 +106,15 @@ read_w32_reg_string (const char *key_arg)
*p2++ = 0;
result = gpgrt_w32_reg_query_string (*key? key : NULL, p1, p2);
+ if (result && !*key && r_hklm_fallback)
+ {
+ /* No key given - see whether the result came from HKCU or HKLM. */
+ result2 = gpgrt_w32_reg_query_string ("HKCU", p1, p2);
+ if (result2)
+ xfree (result2);
+ else
+ *r_hklm_fallback = 1;
+ }
xfree (key);
return result;
}
diff --git a/common/w32help.h b/common/w32help.h
index 33000acc7..5a4e5752c 100644
--- a/common/w32help.h
+++ b/common/w32help.h
@@ -44,7 +44,7 @@ char **w32_parse_commandline (char *cmdline, int globing, int *r_argv,
/*-- w32-reg.c --*/
char *read_w32_registry_string (const char *root,
const char *dir, const char *name );
-char *read_w32_reg_string (const char *key);
+char *read_w32_reg_string (const char *key, int *r_hklm_fallback);
#endif /*HAVE_W32_SYSTEM*/