testdll.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. {
  2. $Id$
  3. Copyright (c) 1998 by Pierre Muller
  4. Win32 DLL usage example. It needs dlltest.pp
  5. }
  6. library testdll;
  7. function GetModuleFileName(hModule:longint;lpszPath:pchar;cchPath:longint):longint;
  8. external 'kernel32' name 'GetModuleFileNameA';
  9. procedure beep(ID:longint);
  10. external 'user32' name 'MessageBeep';
  11. var
  12. teststr : string;
  13. procedure P1(var s:string);export;
  14. var
  15. p:array[0..255] of char;
  16. begin
  17. length(s);
  18. getmodulefilename(Hinstance,@p,255);
  19. writeln('DLL: Hello, I''m DLL ',pchar(@p));
  20. end;
  21. procedure P2(x:longint);export;
  22. begin
  23. writeln('DLL: Argument X=',x);
  24. writeln('DLL: New teststr="',teststr,'"');
  25. end;
  26. procedure P3(var t);export;
  27. var
  28. p : pointer;
  29. begin
  30. p:=Addr(T);
  31. p:=p;
  32. end;
  33. procedure P4(x1:pointer);export;
  34. begin
  35. Inc(x1);
  36. end;
  37. procedure NewExit;
  38. begin
  39. beep(0);
  40. writeln('DLL: Exit from testdll');
  41. end;
  42. exports
  43. P1 index 1,
  44. P2 name 'Proc2',
  45. P3,
  46. P4 resident,
  47. teststr name 'FPC_string';
  48. begin
  49. writeln('DLL: HInstance ',Hinstance,' PrevInst ',Hprevinst,' DLLReason ',DLLreason,' DLLParam ',DLLparam);
  50. teststr:='DLL init done';
  51. exitproc:=@newExit;
  52. end.
  53. {
  54. $Log$
  55. Revision 1.5 2000-02-22 03:46:55 alex
  56. fixed the warning
  57. Revision 1.4 2000/01/21 00:44:51 peter
  58. * remove unused vars
  59. * renamed to .pp
  60. Revision 1.3 1999/10/26 12:33:53 peter
  61. * fixed illegal expr
  62. Revision 1.2 1999/06/30 22:04:56 michael
  63. * Added code to remove warnings
  64. Revision 1.1 1999/01/12 14:20:36 peter
  65. + dll example
  66. }