dynlibs.pp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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-independent 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. {$MODE OBJFPC}
  12. unit dynlibs;
  13. interface
  14. { ---------------------------------------------------------------------
  15. Read OS-dependent interface declarations.
  16. ---------------------------------------------------------------------}
  17. {$define readinterface}
  18. {$i dynlibs.inc}
  19. {$undef readinterface}
  20. { ---------------------------------------------------------------------
  21. OS - Independent declarations.
  22. ---------------------------------------------------------------------}
  23. Function LoadLibrary(Name : AnsiString) : TLibHandle;
  24. Function GetProcedureAddress(Lib : TlibHandle; ProcName : AnsiString) : Pointer;
  25. Function UnloadLibrary(Lib : TLibHandle) : Boolean;
  26. // Kylix/Delphi compability
  27. Function FreeLibrary(Lib : TLibHandle) : Boolean;
  28. Function GetProcAddress(Lib : TlibHandle; ProcName : AnsiString) : Pointer;
  29. Type
  30. HModule = TLibHandle;
  31. Implementation
  32. { ---------------------------------------------------------------------
  33. OS - Independent declarations.
  34. ---------------------------------------------------------------------}
  35. {$i dynlibs.inc}
  36. Function FreeLibrary(Lib : TLibHandle) : Boolean;
  37. begin
  38. Result:=UnloadLibrary(lib);
  39. end;
  40. Function GetProcAddress(Lib : TlibHandle; ProcName : AnsiString) : Pointer;
  41. begin
  42. Result:=GetProcedureAddress(Lib,Procname);
  43. end;
  44. end.