dynlibs.inc 1.6 KB

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