dynlibs.inc 1.8 KB

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