Selaa lähdekoodia

* Added GetLoadErrorStr function by Mark Morgan Loyd (Bug ID 22321)

git-svn-id: trunk@21880 -
michael 13 vuotta sitten
vanhempi
commit
8eeb22720b

+ 1 - 0
rtl/inc/dynlibs.pas

@@ -37,6 +37,7 @@ Function SafeLoadLibrary(const Name : AnsiString) : TLibHandle;
 Function LoadLibrary(const Name : AnsiString) : TLibHandle;
 Function GetProcedureAddress(Lib : TlibHandle; const ProcName : AnsiString) : Pointer;
 Function UnloadLibrary(Lib : TLibHandle) : Boolean;
+Function GetLoadErrorStr: string;
 
 // Kylix/Delphi compability
 

+ 6 - 0
rtl/netware/dynlibs.inc

@@ -56,5 +56,11 @@ begin
   Result:=false;
 end;
 
+
+Function GetLoadErrorStr: string;
+
+begin  
+  Result:='';
+end;
 {$endif}
 

+ 5 - 0
rtl/netwlibc/dynlibs.inc

@@ -53,5 +53,10 @@ begin
   Result:=dlClose(Lib)=0;
 end;
 
+Function GetLoadErrorStr: string;
+
+begin  
+  Result:='';
+end;
 {$endif}
 

+ 5 - 0
rtl/os2/dynlibs.inc

@@ -59,5 +59,10 @@ begin
  Result := DosFreeModule (Lib) = 0;
 end;
 
+Function GetLoadErrorStr: string;
+
+begin
+  Result:='';
+end;
 {$endif}
 

+ 6 - 0
rtl/unix/dynlibs.inc

@@ -75,5 +75,11 @@ begin
   Result:=dlClose(Lib)=0;
 end;
 
+Function GetLoadErrorStr: string;
+
+begin
+  Result:=dl.dlerror;
+end;
+
 {$endif}
 

+ 15 - 0
rtl/win/dynlibs.inc

@@ -54,5 +54,20 @@ begin
   Result:=Windows.FreeLibrary(Lib);
 end;
 
+Function GetLoadErrorStr: string;
+
+Var
+  rc : integer;
+begin  
+  rc := GetLastError;
+  try
+    result := Trim(SysErrorMessage(rc));
+    if (result='') then
+      result := 'Operating system error 0x' + IntToHex(rc, 8) + ' (no descriptive text)'
+  except
+    result := 'Operating system error 0x' + IntToHex(rc, 8) + ' (error getting descriptive text)'
+  end;
+end;
+
 {$endif}
 

+ 15 - 0
rtl/wince/dynlibs.inc

@@ -59,4 +59,19 @@ begin
   Result:=Windows.FreeLibrary(Lib);
 end;
 
+Function GetLoadErrorStr: string;
+
+Var
+  rc : integer;
+begin  
+  rc := GetLastError;
+  try
+    result := Trim(SysErrorMessage(rc));
+    if (result='') then
+      result := 'Operating system error 0x' + IntToHex(rc, 8) + ' (no descriptive text)'
+  except
+    result := 'Operating system error 0x' + IntToHex(rc, 8) + ' (error getting descriptive text)'
+  end;
+end;
+
 {$endif}