dynlibs.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2004 by the Free Pascal development team
  4. Implement OS-dependent part of dynamic library loading.
  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 = Pointer;
  17. Const
  18. NilHandle = Nil;
  19. {$else}
  20. { ---------------------------------------------------------------------
  21. Implementation section
  22. ---------------------------------------------------------------------}
  23. uses libc;
  24. Function LoadLibrary(Name : AnsiString) : TLibHandle;
  25. begin
  26. Result:=dlopen(Pchar(Name),RTLD_LAZY);
  27. end;
  28. Function GetProcedureAddress(Lib : TLibHandle; ProcName : AnsiString) : Pointer;
  29. begin
  30. Result:=dlsym(lib,pchar(ProcName));
  31. end;
  32. Function UnloadLibrary(Lib : TLibHandle) : Boolean;
  33. begin
  34. Result:=dlClose(Lib)=0;
  35. end;
  36. {$endif}