mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: mbLoadLibraryEx function
This commit is contained in:
parent
ab26e0eafb
commit
2dd9817eb9
1 changed files with 13 additions and 20 deletions
|
|
@ -1898,35 +1898,28 @@ const
|
|||
PATH_ENV = 'PATH';
|
||||
var
|
||||
APath: String;
|
||||
FullName: String;
|
||||
usName: UnicodeString;
|
||||
begin
|
||||
FullName:= Name;
|
||||
usName:= CeUtf8ToUtf16(Name);
|
||||
|
||||
if GetPathType(Name) = ptNone then
|
||||
begin
|
||||
FindInSystemPath(FullName);
|
||||
end;
|
||||
usName:= CeUtf8ToUtf16(FullName);
|
||||
|
||||
if CheckWin32Version(10)then
|
||||
if CheckWin32Version(10) or (GetProcAddress(GetModuleHandleW(Kernel32), 'AddDllDirectory') <> nil) then
|
||||
begin
|
||||
Result:= LoadLibraryExW(PWideChar(usName), 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR or LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
|
||||
end
|
||||
else if CheckWin32Version(6) then
|
||||
begin
|
||||
SetDllDirectoryW(PWideChar(ExtractFileDir(usName)));
|
||||
try
|
||||
Result:= LoadLibraryW(PWideChar(usName));
|
||||
finally
|
||||
SetDllDirectoryW(nil);
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
APath:= mbGetEnvironmentVariable(PATH_ENV);
|
||||
try
|
||||
mbSetEnvironmentVariable(PATH_ENV, ExtractFileDir(Name));
|
||||
Result:= LoadLibraryW(PWideChar(usName));
|
||||
if GetPathType(Name) <> ptAbsolute then
|
||||
SetDllDirectoryW(PWideChar(''))
|
||||
else begin
|
||||
SetDllDirectoryW(PWideChar(ExtractFileDir(usName)));
|
||||
end;
|
||||
try
|
||||
SetEnvironmentVariableW(PATH_ENV, nil);
|
||||
Result:= LoadLibraryW(PWideChar(usName));
|
||||
finally
|
||||
SetDllDirectoryW(nil);
|
||||
end;
|
||||
finally
|
||||
mbSetEnvironmentVariable(PATH_ENV, APath);
|
||||
end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue