Kaynağa Gözat

FIX: Save last error

Alexander Koblov 1 yıl önce
ebeveyn
işleme
4b6bfe3345
1 değiştirilmiş dosya ile 7 ekleme ve 4 silme
  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}