aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/misc.c')
-rw-r--r--g10/misc.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 0bf71c264..9f412f3de 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1155,24 +1155,29 @@ get_libexecdir (void)
{
#ifdef HAVE_W32_SYSTEM
static int got_dir;
- static char *dir;
+ static char dir[MAX_PATH+5];
if (!got_dir)
{
- dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE",
- "Software\\GNU\\GnuPG",
- "Install Directory");
- if (dir && !*dir)
+ char *p;
+
+ if ( !GetModuleFileName ( NULL, dir, MAX_PATH) )
{
- /* To avoid problems with using an empty dir we don't allow
- for that. */
- free (dir);
- dir = NULL;
+ log_debug ("GetModuleFileName failed: %s\n", w32_strerror (0));
+ *dir = 0;
}
got_dir = 1;
+ p = strrchr (dir, DIRSEP_C);
+ if (p)
+ *p = 0;
+ else
+ {
+ log_debug ("bad filename `%s' returned for this process\n", dir);
+ *dir = 0;
+ }
}
- if (dir)
+ if (*dir)
return dir;
/* Fallback to the hardwired value. */
#endif /*HAVE_W32_SYSTEM*/