InnoCallback_Example.iss 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. [Setup]
  2. AppName=My Program
  3. AppVerName=My Program 1.5
  4. AppPublisher=My Company, Inc.
  5. AppPublisherURL=http://www.mycompany.com
  6. AppSupportURL=http://www.mycompany.com
  7. AppUpdatesURL=http://www.mycompany.com
  8. CreateAppDir=no
  9. OutputBaseFilename=setup
  10. Compression=lzma
  11. SolidCompression=true
  12. OutputDir=userdocs:Inno Setup Examples Output
  13. [Files]
  14. Source: InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy
  15. [Code]
  16. (*
  17. Inno Tools InnoCallback
  18. Copyright (C) Sherlock Software 2006
  19. Version 0.1 Alpha
  20. This example shows how you can create a stdcall callback that external DLLs can call.
  21. In this example, we will create a timer using the Windows API. Windows will call our
  22. callback where we will randomly change the background color of the Welcome page.
  23. Contact:
  24. The author, Nicholas Sherlock, at nick@sherlocksoftware.org. Comments, questions and suggestions welcome.
  25. Website:
  26. http://www.sherlocksoftware.org
  27. *)
  28. type
  29. TTimerProc=procedure(h:longword; msg:longword; idevent:longword; dwTime:longword);
  30. TMyCallback=function(a,b,c:integer):integer;
  31. function WrapTimerProc(callback:TTimerProc; paramcount:integer):longword;
  32. external 'InnoCallback@files:innocallback.dll stdcall';
  33. function WrapMyCallback(callback:TMyCallBack; paramcount:integer):longword;
  34. external 'InnoCallback@files:innocallback.dll stdcall';
  35. function SetTimer(hWnd: longword; nIDEvent, uElapse: longword; lpTimerFunc: longword): longword;
  36. external 'SetTimer@user32.dll stdcall';
  37. //Note, we musn't declare our routine as Stdcall
  38. procedure mytimerproc(h:longword; msg:longword; idevent:longword; dwTime:longword);
  39. begin
  40. pagefromid(wpWelcome).surface.color:=random($FFFFFF);
  41. end;
  42. {This callback isn't used in this example, but it shows how you should
  43. duplicate the Wrap() procedures to wrap different functions}
  44. function mycallback(a,b,c:integer):integer;
  45. begin
  46. result:=a*b*c;
  47. end;
  48. function InitializeSetup:boolean;
  49. var timercallback,callback:longword;
  50. begin
  51. timercallback:=WrapTimerProc(@mytimerproc,4); //Our proc has 4 arguments
  52. callback:=WrapMyCallback(@mycallback,3); //Our proc has 3 arguments
  53. settimer(0,0,1000,timercallback); //Create a timer and give it our callback as an argument
  54. result:=true; //keep loading setup..
  55. end;