diff options
author | Jesper Dam <jalf@medical-insight.com> | 2011-10-28 15:54:30 +0200 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2011-10-28 21:01:02 +0200 |
commit | d52b86d3e774ed515039f47b2a35ec645362a97b (patch) | |
tree | 4fa49d55a197a2c2277a64e4681e6d6fd1afbf1c | |
parent | ff3f4860ef9cdd247e515058eef4642223b32e0b (diff) |
Find dbus-daemon executable next to dbus shared libaray on windows.
If the dbus shared library and the daemon executable are both in a dir
that is not part of the default search path and dbus-1.dll is dynamically
loaded with LoadLibrary(), it will fail to locate and launch the daemon
without this patch.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41558
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
-rw-r--r-- | dbus/dbus-sysdeps-win.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index a8c60bda..3bcf86ac 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2861,11 +2861,25 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address, if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile)) { - printf ("please add the path to %s to your PATH environment variable\n", daemon_name); - printf ("or start the daemon manually\n\n"); - goto out; + // Look in directory containing dbus shared library + HMODULE hmod = _dbus_win_get_dll_hmodule(); + char dbus_module_path[MAX_PATH]; + DWORD rc = GetModuleFileNameA(hmod, dbus_module_path, sizeof(dbus_module_path)); + if (rc > 0) + { + char *ext_idx = strrchr(dbus_module_path, '\\'); + if (ext_idx) + *ext_idx = '\0'; + if (!SearchPathA(dbus_module_path, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile)) + { + printf ("please add the path to %s to your PATH environment variable\n", daemon_name); + printf ("or start the daemon manually\n\n"); + goto out; + } + } } + // Create process ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); |