| 1 |
{ |
| 2 |
NSIS ExDLL2 example |
| 3 |
Original is ExDLL |
| 4 |
(C) 2001 - Peter Windridge |
| 5 |
|
| 6 |
Changed with delphi unit nsis.pas |
| 7 |
by bernhard mayer |
| 8 |
|
| 9 |
Tested in Delphi 7.0 |
| 10 |
} |
| 11 |
|
| 12 |
// Example NSIS code |
| 13 |
{ |
| 14 |
Section |
| 15 |
exdll_with_unit::registerplugincallback |
| 16 |
|
| 17 |
StrCpy $3 "Hello" |
| 18 |
Push "World" |
| 19 |
exdll_with_unit::pop_dlg_push |
| 20 |
Pop $1 |
| 21 |
DetailPrint $$1=$1 |
| 22 |
DetailPrint $$3=$3 |
| 23 |
|
| 24 |
GetFunctionAddress $0 nsistest |
| 25 |
Push $0 |
| 26 |
exdll_with_unit::callnsisfunc |
| 27 |
SectionEnd |
| 28 |
|
| 29 |
Function nsistest |
| 30 |
DetailPrint "Hello from NSIS function" |
| 31 |
FunctionEnd |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
library exdll; |
| 36 |
|
| 37 |
uses |
| 38 |
nsis, windows; |
| 39 |
|
| 40 |
{$IFDEF UNICODE} |
| 41 |
type TString = System.WideString; // UnicodeString? |
| 42 |
type PTChar = PWideChar; |
| 43 |
{$ELSE} |
| 44 |
type TString = AnsiString; |
| 45 |
type PTChar = PAnsiChar; |
| 46 |
{$ENDIF} |
| 47 |
|
| 48 |
procedure pop_dlg_push(const hwndParent: HWND; const string_size: integer; const variables: PTChar; const stacktop: pointer); cdecl; |
| 49 |
begin |
| 50 |
// set up global variables |
| 51 |
Init(hwndParent, string_size, variables, stacktop); |
| 52 |
|
| 53 |
NSISDialog(GetUserVariable(INST_3), 'The value of $3', MB_OK); |
| 54 |
NSISDialog(PopString, 'pop', MB_OK); |
| 55 |
PushString('Hello, this is a push'); |
| 56 |
SetUserVariable(INST_3, 'This is user var $3'); |
| 57 |
end; |
| 58 |
|
| 59 |
|
| 60 |
procedure callnsisfunc(const hwndParent: HWND; const string_size: integer; const variables: PTChar; const stacktop: pointer; const extraparameters: pointer); cdecl; |
| 61 |
var |
| 62 |
FuncAddr : TString; |
| 63 |
begin |
| 64 |
Init(hwndParent, string_size, variables, stacktop, extraparameters); |
| 65 |
|
| 66 |
FuncAddr := PopString(); |
| 67 |
Call(FuncAddr); |
| 68 |
end; |
| 69 |
|
| 70 |
|
| 71 |
function mynsiscallback(const NSPIM: TNSPIM): Pointer; cdecl; |
| 72 |
begin |
| 73 |
Result := nil; |
| 74 |
if NSPIM = NSPIM_UNLOAD then |
| 75 |
begin |
| 76 |
NSISDialog(PTChar('NSPIM_UNLOAD is the final callback, goodbye...'), PTChar('mynsiscallback'), MB_OK); |
| 77 |
end; |
| 78 |
end; |
| 79 |
|
| 80 |
|
| 81 |
procedure registerplugincallback(const hwndParent: HWND; const string_size: integer; const variables: PTChar; const stacktop: pointer; const extraparameters: pointer); cdecl; |
| 82 |
var |
| 83 |
ThisDllInstance : HMODULE; |
| 84 |
begin |
| 85 |
Init(hwndParent, string_size, variables, stacktop, extraparameters); |
| 86 |
|
| 87 |
if g_extraparameters <> nil then |
| 88 |
begin |
| 89 |
ThisDllInstance := hInstance; |
| 90 |
TRegisterPluginCallback(g_extraparameters.RegisterPluginCallback)(ThisDllInstance, @mynsiscallback); |
| 91 |
end; |
| 92 |
end; |
| 93 |
|
| 94 |
|
| 95 |
exports pop_dlg_push; |
| 96 |
exports callnsisfunc; |
| 97 |
exports registerplugincallback; |
| 98 |
|
| 99 |
begin |
| 100 |
end. |