Skip to content

Commit a1ba9b0

Browse files
committed
1 parent 935cff0 commit a1ba9b0

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Source/PythonEngine.pas

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,17 +2909,26 @@ procedure TPythonInputOutput.UpdateCurrentThreadLine;
29092909
(*******************************************************)
29102910

29112911
procedure TDynamicDll.DoOpenDll(const aDllName : string);
2912+
{$IFDEF MSWINDOWS}
2913+
const
2914+
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = $00000100;
2915+
LOAD_LIBRARY_DEFAULT_DIRS = $00001000;
2916+
Var
2917+
ExceptMask: TFPUExceptionMask;
2918+
{$ENDIF}
29122919
begin
29132920
if not IsHandleValid then
29142921
begin
29152922
FDllName := aDllName;
29162923
{$IFDEF MSWINDOWS}
2917-
FDLLHandle := SafeLoadLibrary(
2918-
{$IFDEF FPC}
2919-
PAnsiChar(AnsiString(GetDllPath+DllName))
2920-
{$ELSE}
2921-
GetDllPath+DllName
2922-
{$ENDIF});
2924+
ExceptMask := GetExceptionMask;
2925+
try
2926+
FDLLHandle := LoadLibraryExA(
2927+
PAnsiChar(AnsiString(GetDllPath+DllName)), 0,
2928+
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR or LOAD_LIBRARY_DEFAULT_DIRS);
2929+
finally
2930+
SetExceptionMask(ExceptMask);
2931+
end;
29232932
{$ELSE}
29242933
//Linux: need here RTLD_GLOBAL, so Python can do "import ctypes"
29252934
FDLLHandle := THandle(dlopen(PAnsiChar(AnsiString(GetDllPath+DllName)),

0 commit comments

Comments
 (0)