mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-21 05:09:31 +02:00
* GetLoadErrorStr implemented
git-svn-id: trunk@21907 -
This commit is contained in:
parent
7717e43929
commit
4dccf2d321
@ -37,32 +37,105 @@ const
|
|||||||
uses
|
uses
|
||||||
DosCalls;
|
DosCalls;
|
||||||
|
|
||||||
|
threadvar
|
||||||
|
DynLibErrNo: cardinal;
|
||||||
|
DynLibErrPath: array [0..259] of char;
|
||||||
|
|
||||||
function LoadLibrary (const Name: AnsiString): TLibHandle;
|
function LoadLibrary (const Name: AnsiString): TLibHandle;
|
||||||
var
|
var
|
||||||
ErrPath: array [0..259] of char;
|
|
||||||
Handle: longint;
|
Handle: longint;
|
||||||
begin
|
begin
|
||||||
if DosLoadModule (@ErrPath, SizeOf (ErrPath), PChar (Name), Handle) = 0
|
DynLibErrPath [0] := #0;
|
||||||
then Result := Handle else Result := NilHandle;
|
DynLibErrNo := DosLoadModule (@DynLibErrPath [0], SizeOf (DynLibErrPath),
|
||||||
|
PChar (Name), Handle);
|
||||||
|
if DynLibErrNo = 0 then
|
||||||
|
Result := Handle
|
||||||
|
else
|
||||||
|
Result := NilHandle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetProcedureAddress (Lib: TLibHandle; const ProcName: AnsiString): pointer;
|
function GetProcedureAddress (Lib: TLibHandle; const ProcName: AnsiString): pointer;
|
||||||
var
|
var
|
||||||
P: pointer;
|
P: pointer;
|
||||||
begin
|
begin
|
||||||
if DosQueryProcAddr (Lib, 0, PChar (ProcName), P) = 0 then Result := P
|
DynLibErrPath [0] := #0;
|
||||||
else Result := nil;
|
DynLibErrNo := DosQueryProcAddr (Lib, 0, PChar (ProcName), P);
|
||||||
|
if DynLibErrNo = 0 then
|
||||||
|
Result := P
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function UnloadLibrary (Lib: TLibHandle): boolean;
|
function UnloadLibrary (Lib: TLibHandle): boolean;
|
||||||
begin
|
begin
|
||||||
Result := DosFreeModule (Lib) = 0;
|
DynLibErrPath [0] := #0;
|
||||||
|
DynLibErrNo := DosFreeModule (Lib);
|
||||||
|
Result := DynLibErrNo = 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function GetLoadErrorStr: string;
|
function GetDynLibsErrorStr: string;
|
||||||
|
const
|
||||||
|
SysMsgFile: array [0..10] of char = 'OSO001.MSG'#0;
|
||||||
|
var
|
||||||
|
VarArr: array [1..9] of PChar;
|
||||||
|
OutBuf: array [0..999] of char;
|
||||||
|
RetMsgSize: cardinal;
|
||||||
|
RC: cardinal;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
if DynLibErrNo = 0 then
|
||||||
|
GetDynLibsErrorStr := ''
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
VarArr [1] := @DynLibErrPath [0];
|
||||||
|
RC := DosGetMessage (@VarArr, 1, @OutBuf [0], SizeOf (OutBuf),
|
||||||
|
DynLibErrNo, @SysMsgFile [0], RetMsgSize);
|
||||||
|
if RC = 0 then
|
||||||
|
Result := StrPas (@OutBuf [0])
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
WriteStr (Result, DynLibErrNo);
|
||||||
|
Result := 'Error ' + Result;
|
||||||
|
end;
|
||||||
|
if DynLibErrPath [0] <> #0 then
|
||||||
|
Result := StrPas (@DynLibErrPath [0]) + ' - ' + Result;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetDynLibsError: longint;
|
||||||
|
begin
|
||||||
|
GetDynLibsError := DynLibErrNo;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetDynLibsErrorStr: string;
|
||||||
|
const
|
||||||
|
SysMsgFile: array [0..10] of char = 'OSO001.MSG'#0;
|
||||||
|
var
|
||||||
|
VarArr: array [1..9] of PChar;
|
||||||
|
OutBuf: array [0..999] of char;
|
||||||
|
RetMsgSize: cardinal;
|
||||||
|
RC: cardinal;
|
||||||
|
begin
|
||||||
|
if DynLibErrNo = 0 then
|
||||||
|
GetDynLibsErrorStr := ''
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
VarArr [1] := @DynLibErrPath [0];
|
||||||
|
RC := DosGetMessage (@VarArr, 1, @OutBuf [0], SizeOf (OutBuf),
|
||||||
|
DynLibErrNo, @SysMsgFile [0], RetMsgSize);
|
||||||
|
if RC = 0 then
|
||||||
|
Result := StrPas (@OutBuf [0])
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
WriteStr (Result, DynLibErrNo);
|
||||||
|
Result := 'Error ' + Result;
|
||||||
|
end;
|
||||||
|
if DynLibErrPath [0] <> #0 then
|
||||||
|
Result := StrPas (@DynLibErrPath [0]) + ' - ' + Result;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetLoadErrorStr: string;
|
||||||
|
begin
|
||||||
|
GetLoadErrorStr := GetDynLibsErrorStr;
|
||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user