dynlibs.pas 1.8 KB

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