dynlibs.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by the Free Pascal development team
  4. Implements OS dependent part for loading of dynamic libraries.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$ifdef readinterface}
  12. { ---------------------------------------------------------------------
  13. Interface declarations
  14. ---------------------------------------------------------------------}
  15. type
  16. TLibHandle = longint;
  17. const
  18. NilHandle = 0;
  19. {$else}
  20. { ---------------------------------------------------------------------
  21. Implementation section
  22. ---------------------------------------------------------------------}
  23. uses
  24. DosCalls;
  25. function LoadLibrary (Name: AnsiString): TLibHandle;
  26. var
  27. ErrPath: array [0..259] of char;
  28. Handle: longint;
  29. begin
  30. if DosLoadModule (@ErrPath, SizeOf (ErrPath), PChar (Name), Handle) = 0
  31. then Result := Handle else Result := NilHandle;
  32. end;
  33. function GetProcedureAddress (Lib: TLibHandle; ProcName: AnsiString): pointer;
  34. var
  35. P: pointer;
  36. begin
  37. if DosQueryProcAddr (Lib, 0, PChar (ProcName), P) = 0 then Result := P
  38. else Result := nil;
  39. end;
  40. function UnloadLibrary (Lib: TLibHandle): boolean;
  41. begin
  42. Result := DosFreeModule (Lib) = 0;
  43. end;
  44. {$endif}