dynlibs.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2011 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 = System.THandle;
  17. Const
  18. NilHandle = 0;
  19. // these are for easier crossplatform construction of dll names in dynloading libs.
  20. SharedSuffix = 'nlm';
  21. {$else}
  22. { ---------------------------------------------------------------------
  23. Implementation section
  24. ---------------------------------------------------------------------}
  25. Uses nwserv;
  26. Function LoadLibrary(const Name : AnsiString) : TlibHandle;
  27. var args : array[0..1] of pchar;
  28. begin
  29. args[0] := pchar(Name);
  30. args[1] := nil;
  31. Result:=spawnvp(P_NOWAIT,@args,nil);
  32. end;
  33. Function GetProcedureAddress(Lib : TLibHandle; const ProcName : AnsiString) : Pointer;
  34. begin
  35. Result:=ImportSymbol(GetNlmHandle, pchar(ProcName));
  36. end;
  37. Function UnloadLibrary(Lib : TLibHandle) : Boolean;
  38. begin
  39. Result:=false;
  40. end;
  41. {$endif}