dynlibs.inc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. {$IFNDEF FPC_DOTTEDUNITS}
  12. Uses nwserv;
  13. {$ELSE}
  14. Uses NetwareApi.nwserv;
  15. {$ENDIF}
  16. Function SysLoadLibraryA(const Name : RawByteString) : TlibHandle;
  17. var args : array[0..1] of PAnsiChar;
  18. begin
  19. args[0] := PAnsiChar(Name);
  20. args[1] := nil;
  21. Result:=spawnvp(P_NOWAIT,@args,nil);
  22. end;
  23. Function SysLoadLibraryU(const Name: UnicodeString) : TLibHandle;
  24. begin
  25. Result := SysLoadLibraryA(ToSingleByteFileSystemEncodedFileName(Name));
  26. end;
  27. Function SysGetProcedureAddress(Lib : TLibHandle; const ProcName : AnsiString) : Pointer;
  28. begin
  29. Result:=ImportSymbol(GetNlmHandle, PAnsiChar(ProcName));
  30. end;
  31. Function SysUnloadLibrary(Lib : TLibHandle) : Boolean;
  32. begin
  33. Result:=false;
  34. end;
  35. Function SysGetLoadErrorStr: AnsiString;
  36. begin
  37. Result:='';
  38. end;
  39. const
  40. SysDynLibsManager: TDynLibsManager = (
  41. LoadLibraryU: @SysLoadLibraryU;
  42. LoadLibraryA: @SysLoadLibraryA;
  43. GetProcAddress: @SysGetProcedureAddress;
  44. GetProcAddressOrdinal: Nil;
  45. UnloadLibrary: @SysUnloadLibrary;
  46. GetLoadErrorStr: @SysGetLoadErrorStr;
  47. );
  48. procedure InitDynLibs;
  49. begin
  50. SetDynLibsManager(SysDynLibsManager);
  51. end;