浏览代码

FIX: Save last error

Alexander Koblov 1 年之前
父节点
当前提交
4b6bfe3345
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      components/doublecmd/dcosutils.pas

+ 7 - 4
components/doublecmd/dcosutils.pas

@@ -1801,16 +1801,19 @@ end;
 function mbLoadLibrary(const Name: String): TLibHandle;
 {$IFDEF MSWINDOWS}
 var
+  dwErrCode: DWORD;
   sRememberPath: String;
 begin
   try
-    //Some plugins using DLL(s) in their directory are loaded correctly only if "CurrentDir" is poining their location.
-    //Also, TC switch "CurrentDir" to their directory when loading them. So let's do the same.
-    sRememberPath:=GetCurrentDir;
-    SetCurrentDir(ExcludeTrailingPathDelimiter(ExtractFilePath(Name)));
+    // Some plugins using DLL(s) in their directory are loaded correctly only if "CurrentDir" is poining their location.
+    // Also, TC switch "CurrentDir" to their directory when loading them. So let's do the same.
+    sRememberPath:= GetCurrentDir;
+    SetCurrentDir(ExtractFileDir(Name));
     Result:= LoadLibraryW(PWideChar(CeUtf8ToUtf16(Name)));
+    dwErrCode:= GetLastError;
   finally
     SetCurrentDir(sRememberPath);
+    SetLastError(dwErrCode);
   end;
 end;
 {$ELSE}