New Delphi unit for NSIS plug-ins by Bernhard Mayer
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2791 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1e438b3e87
commit
aec369dfbc
2 changed files with 157 additions and 0 deletions
37
Contrib/ExDLL/exdll_with_unit.dpr
Normal file
37
Contrib/ExDLL/exdll_with_unit.dpr
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
NSIS ExDLL2 example
|
||||
Original is ExDLL
|
||||
(C) 2001 - Peter Windridge
|
||||
|
||||
Changed with delphi unit nsis.pas
|
||||
by bernhard mayer
|
||||
|
||||
Tested in Delphi 7.0
|
||||
}
|
||||
|
||||
library exdll;
|
||||
|
||||
uses
|
||||
nsis, windows;
|
||||
|
||||
function ex_dll(hwndParent: HWND; string_size: integer; variables: PChar; stacktop: pointer):integer; cdecl;
|
||||
var
|
||||
c: PChar;
|
||||
buf: array[0..1024] of char;
|
||||
begin
|
||||
// set up global variables
|
||||
Init(hwndParent,string_size,variables,stacktop);
|
||||
|
||||
c:=GetUserVariable(INST_0);
|
||||
MessageBox(g_hwndParent,c,'The value of $0',MB_OK);
|
||||
PopString(@buf);
|
||||
MessageBox(g_hwndParent,@buf,'pop',MB_OK);
|
||||
PushString(PChar('Hello, this is a push'));
|
||||
|
||||
Result:=1;
|
||||
end;
|
||||
|
||||
exports ex_dll;
|
||||
|
||||
begin
|
||||
end.
|
120
Contrib/ExDLL/nsis.pas
Normal file
120
Contrib/ExDLL/nsis.pas
Normal file
|
@ -0,0 +1,120 @@
|
|||
{
|
||||
Original Code from
|
||||
(C) 2001 - Peter Windridge
|
||||
|
||||
Code in seperate unit and some changes
|
||||
2003 by Bernhard Mayer
|
||||
|
||||
simple include this unit in your plugin project and export
|
||||
functions as needed
|
||||
}
|
||||
|
||||
|
||||
unit nsis;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
windows;
|
||||
|
||||
type
|
||||
VarConstants = (
|
||||
INST_0,
|
||||
INST_1, // $1
|
||||
INST_2, // $2
|
||||
INST_3, // $3
|
||||
INST_4, // $4
|
||||
INST_5, // $5
|
||||
INST_6, // $6
|
||||
INST_7, // $7
|
||||
INST_8, // $8
|
||||
INST_9, // $9
|
||||
INST_R0, // $R0
|
||||
INST_R1, // $R1
|
||||
INST_R2, // $R2
|
||||
INST_R3, // $R3
|
||||
INST_R4, // $R4
|
||||
INST_R5, // $R5
|
||||
INST_R6, // $R6
|
||||
INST_R7, // $R7
|
||||
INST_R8, // $R8
|
||||
INST_R9, // $R9
|
||||
INST_CMDLINE, // $CMDLINE
|
||||
INST_INSTDIR, // $INSTDIR
|
||||
INST_OUTDIR, // $OUTDIR
|
||||
INST_EXEDIR, // $EXEDIR
|
||||
INST_LANG, // $LANGUAGE
|
||||
__INST_LAST
|
||||
);
|
||||
TVariableList = INST_0..__INST_LAST;
|
||||
pstack_t = ^stack_t;
|
||||
stack_t = record
|
||||
next: pstack_t;
|
||||
text: PChar;
|
||||
end;
|
||||
|
||||
var
|
||||
g_stringsize: integer;
|
||||
g_stacktop: ^pstack_t;
|
||||
g_variables: PChar;
|
||||
g_hwndParent: HWND;
|
||||
|
||||
procedure Init(hwndParent: HWND; string_size: integer; variables: PChar; stacktop: pointer);
|
||||
function PopString(str: PChar):integer;
|
||||
function PushString(str: PChar):integer;
|
||||
function GetUserVariable(varnum: TVariableList):PChar;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Init(hwndParent: HWND; string_size: integer; variables: PChar; stacktop: pointer);
|
||||
begin
|
||||
g_stringsize:=string_size;
|
||||
g_hwndParent:=hwndParent;
|
||||
g_stacktop:=stacktop;
|
||||
g_variables:=variables;
|
||||
end;
|
||||
|
||||
function PopString(str: PChar):integer;
|
||||
var
|
||||
th: pstack_t;
|
||||
begin
|
||||
if integer(g_stacktop^) = 0 then
|
||||
begin
|
||||
Result:=1;
|
||||
Exit;
|
||||
end;
|
||||
th:=g_stacktop^;
|
||||
lstrcpy(str,@th.text);
|
||||
g_stacktop^ := th.next;
|
||||
GlobalFree(HGLOBAL(th));
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function PushString(str: PChar):integer;
|
||||
var
|
||||
th: pstack_t;
|
||||
begin
|
||||
if integer(g_stacktop) = 0 then
|
||||
begin
|
||||
Result:=1;
|
||||
Exit;
|
||||
end;
|
||||
th:=pstack_t(GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize));
|
||||
lstrcpyn(@th.text,str,g_stringsize);
|
||||
th.next:=g_stacktop^;
|
||||
g_stacktop^:=th;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function GetUserVariable(varnum: TVariableList):PChar;
|
||||
begin
|
||||
if (integer(varnum) < 0) or (integer(varnum) >= integer(__INST_LAST)) then
|
||||
begin
|
||||
Result:='';
|
||||
Exit;
|
||||
end;
|
||||
Result:=g_variables+integer(varnum)*g_stringsize;
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
Loading…
Add table
Add a link
Reference in a new issue