From 060332e319e88a16d7742c82882007abbf8075fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Mon, 22 Oct 2018 22:57:37 +0200 Subject: [PATCH] Windows: Add folder to DLL search This makes python look into the `bin` folder when searching for DLLs before it trys C:\Windows or C:\Windows\system32 and potentially finds other versions of DLLs Fixes #8968 --- win/misc/create-launcher.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/win/misc/create-launcher.py b/win/misc/create-launcher.py index d6945d3e0..848ab0591 100644 --- a/win/misc/create-launcher.py +++ b/win/misc/create-launcher.py @@ -87,10 +87,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, Py_FrozenFlag = 1; Py_Initialize(); PySys_SetArgvEx(__argc, szArglist, 0); - result = PyRun_SimpleString("import sys; import os;" - "sys.frozen=True;" - "from gajim import gajim;" - "gajim.main();"); + result = PyRun_SimpleString( + "import sys; import os;" + "sys.frozen=True;" + "from pathlib import Path;" + "root_path = Path(sys.executable).parents[1];" + "from ctypes import windll;" + "windll.kernel32.SetDllDirectoryW(str(root_path / 'bin'));" + "from gajim import gajim;" + "gajim.main();"); Py_Finalize(); return result; }