exdll_with_unit.dpr 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. {
  2. NSIS ExDLL2 example
  3. Original is ExDLL
  4. (C) 2001 - Peter Windridge
  5. Changed with delphi unit nsis.pas
  6. by bernhard mayer
  7. Tested in Delphi 7.0
  8. }
  9. // Example NSIS code
  10. {
  11. Section
  12. exdll_with_unit::registerplugincallback
  13. StrCpy $0 "Hello"
  14. Push "World"
  15. exdll_with_unit::pop_dlg_push
  16. Pop $1
  17. DetailPrint $$0=$0
  18. DetailPrint $$1=$1
  19. GetFunctionAddress $0 nsistest
  20. Push $0
  21. exdll_with_unit::callnsisfunc
  22. SectionEnd
  23. Function nsistest
  24. DetailPrint "Hello from NSIS function"
  25. FunctionEnd
  26. }
  27. library exdll;
  28. uses
  29. nsis, windows;
  30. procedure pop_dlg_push(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl;
  31. begin
  32. // set up global variables
  33. Init(hwndParent, string_size, variables, stacktop);
  34. NSISDialog(GetUserVariable(INST_0), 'The value of $0', MB_OK);
  35. NSISDialog(PopString, 'pop', MB_OK);
  36. PushString('Hello, this is a push');
  37. SetUserVariable(INST_0, 'This is user var $0');
  38. end;
  39. procedure callnsisfunc(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer; const extraparameters: pointer); cdecl;
  40. var
  41. FuncAddr : String;
  42. begin
  43. Init(hwndParent, string_size, variables, stacktop, extraparameters);
  44. FuncAddr := PopString();
  45. Call(FuncAddr);
  46. end;
  47. function mynsiscallback(const NSPIM: TNSPIM): Pointer; cdecl;
  48. begin
  49. Result := nil;
  50. if NSPIM = NSPIM_UNLOAD then
  51. begin
  52. NSISDialog(PChar('NSPIM_UNLOAD is the final callback, goodbye...'), PChar('mynsiscallback'), MB_OK);
  53. end;
  54. end;
  55. procedure registerplugincallback(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer; const extraparameters: pointer); cdecl;
  56. var
  57. ThisDllInstance : HMODULE;
  58. begin
  59. Init(hwndParent, string_size, variables, stacktop, extraparameters);
  60. if g_extraparameters <> nil then
  61. begin
  62. ThisDllInstance := hInstance;
  63. TRegisterPluginCallback(g_extraparameters.RegisterPluginCallback)(ThisDllInstance, @mynsiscallback);
  64. end;
  65. end;
  66. exports pop_dlg_push;
  67. exports callnsisfunc;
  68. exports registerplugincallback;
  69. begin
  70. end.