Plugin SDK Pascal fixes
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6574 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
4e380605ea
commit
544711c803
2 changed files with 78 additions and 20 deletions
|
@ -9,12 +9,36 @@
|
||||||
Tested in Delphi 7.0
|
Tested in Delphi 7.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Example NSIS code
|
||||||
|
{
|
||||||
|
Section
|
||||||
|
exdll_with_unit::registerplugincallback
|
||||||
|
|
||||||
|
StrCpy $0 "Hello"
|
||||||
|
Push "World"
|
||||||
|
exdll_with_unit::pop_dlg_push
|
||||||
|
Pop $1
|
||||||
|
DetailPrint $$0=$0
|
||||||
|
DetailPrint $$1=$1
|
||||||
|
|
||||||
|
GetFunctionAddress $0 nsistest
|
||||||
|
Push $0
|
||||||
|
exdll_with_unit::callnsisfunc
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Function nsistest
|
||||||
|
DetailPrint "Hello from NSIS function"
|
||||||
|
FunctionEnd
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
library exdll;
|
library exdll;
|
||||||
|
|
||||||
uses
|
uses
|
||||||
nsis, windows;
|
nsis, windows;
|
||||||
|
|
||||||
procedure ex_dll(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl;
|
|
||||||
|
procedure pop_dlg_push(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl;
|
||||||
begin
|
begin
|
||||||
// set up global variables
|
// set up global variables
|
||||||
Init(hwndParent, string_size, variables, stacktop);
|
Init(hwndParent, string_size, variables, stacktop);
|
||||||
|
@ -25,7 +49,46 @@ begin
|
||||||
SetUserVariable(INST_0, 'This is user var $0');
|
SetUserVariable(INST_0, 'This is user var $0');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
exports ex_dll;
|
|
||||||
|
procedure callnsisfunc(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer; const extraparameters: pointer); cdecl;
|
||||||
|
var
|
||||||
|
FuncAddr : String;
|
||||||
|
begin
|
||||||
|
Init(hwndParent, string_size, variables, stacktop, extraparameters);
|
||||||
|
|
||||||
|
FuncAddr := PopString();
|
||||||
|
Call(FuncAddr);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function mynsiscallback(const NSPIM: TNSPIM): Pointer; cdecl;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
if NSPIM = NSPIM_UNLOAD then
|
||||||
|
begin
|
||||||
|
// Note: Cannot use NSISDialog here because g_hwndParent has been destroyed at this point
|
||||||
|
MessageBox(0, PChar('NSPIM_UNLOAD is the final callback, goodbye...'), PChar('mynsiscallback'), MB_OK);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure registerplugincallback(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer; const extraparameters: pointer); cdecl;
|
||||||
|
var
|
||||||
|
ThisDllInstance : HMODULE;
|
||||||
|
begin
|
||||||
|
Init(hwndParent, string_size, variables, stacktop, extraparameters);
|
||||||
|
|
||||||
|
if g_extraparameters <> nil then
|
||||||
|
begin
|
||||||
|
ThisDllInstance := hInstance;
|
||||||
|
TRegisterPluginCallback(g_extraparameters.RegisterPluginCallback)(ThisDllInstance, @mynsiscallback);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
exports pop_dlg_push;
|
||||||
|
exports callnsisfunc;
|
||||||
|
exports registerplugincallback;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -52,12 +52,12 @@ type
|
||||||
|
|
||||||
type
|
type
|
||||||
PluginCallbackMessages = (
|
PluginCallbackMessages = (
|
||||||
NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
|
NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
|
||||||
NSPIM_GUIUNLOAD, // Called after .onGUIEnd
|
NSPIM_GUIUNLOAD // Called after .onGUIEnd
|
||||||
);
|
);
|
||||||
TNSPIM = NSPIM_UNLOAD..NSPIM_GUIUNLOAD;
|
TNSPIM = NSPIM_UNLOAD..NSPIM_GUIUNLOAD;
|
||||||
|
|
||||||
//TPluginCallback = function (const NSPIM: Integer): Pointer;
|
//TPluginCallback = function (const NSPIM: Integer): Pointer; cdecl;
|
||||||
|
|
||||||
TExecuteCodeSegment = function (const funct_id: Integer; const parent: HWND): Integer; stdcall;
|
TExecuteCodeSegment = function (const funct_id: Integer; const parent: HWND): Integer; stdcall;
|
||||||
Tvalidate_filename = procedure (const filename: PChar); stdcall;
|
Tvalidate_filename = procedure (const filename: PChar); stdcall;
|
||||||
|
@ -84,7 +84,7 @@ type
|
||||||
pextrap_t = ^extrap_t;
|
pextrap_t = ^extrap_t;
|
||||||
extrap_t = record
|
extrap_t = record
|
||||||
exec_flags: Pointer; // exec_flags_t;
|
exec_flags: Pointer; // exec_flags_t;
|
||||||
exec_code_segment: Pointer; // TFarProc;
|
exec_code_segment: TExecuteCodeSegment; // TFarProc;
|
||||||
validate_filename: Pointer; // Tvalidate_filename;
|
validate_filename: Pointer; // Tvalidate_filename;
|
||||||
RegisterPluginCallback: Pointer; //TRegisterPluginCallback;
|
RegisterPluginCallback: Pointer; //TRegisterPluginCallback;
|
||||||
end;
|
end;
|
||||||
|
@ -102,10 +102,7 @@ var
|
||||||
g_hwndParent: HWND;
|
g_hwndParent: HWND;
|
||||||
g_hwndList: HWND;
|
g_hwndList: HWND;
|
||||||
g_hwndLogList: HWND;
|
g_hwndLogList: HWND;
|
||||||
|
|
||||||
g_extraparameters: pextrap_t;
|
g_extraparameters: pextrap_t;
|
||||||
func : TExecuteCodeSegment;
|
|
||||||
extrap : extrap_t;
|
|
||||||
|
|
||||||
procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer; const extraparameters: pointer = nil);
|
procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer; const extraparameters: pointer = nil);
|
||||||
|
|
||||||
|
@ -125,23 +122,21 @@ begin
|
||||||
g_hwndParent := hwndParent;
|
g_hwndParent := hwndParent;
|
||||||
g_stacktop := stacktop;
|
g_stacktop := stacktop;
|
||||||
g_variables := variables;
|
g_variables := variables;
|
||||||
g_hwndList := 0;
|
g_hwndList := FindWindowEx(FindWindowEx(g_hwndParent, 0, '#32770', nil), 0,'SysListView32', nil);
|
||||||
g_hwndList := FindWindowEx(FindWindowEx(g_hwndParent, 0, '#32770', nil), 0,'SysListView32', nil);
|
|
||||||
g_extraparameters := extraparameters;
|
g_extraparameters := extraparameters;
|
||||||
extrap := g_extraparameters^;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function Call(NSIS_func : String) : Integer;
|
function Call(NSIS_func : String) : Integer;
|
||||||
var
|
var
|
||||||
NSISFun: Integer; //The ID of nsis function
|
codeoffset: Integer; //The ID of nsis function
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
NSISFun := StrToIntDef(NSIS_func, 0);
|
codeoffset := StrToIntDef(NSIS_func, 0);
|
||||||
if (NSISFun <> 0) and (g_extraparameters <> nil) then
|
if (codeoffset <> 0) and (g_extraparameters <> nil) then
|
||||||
begin
|
begin
|
||||||
@func := extrap.exec_code_segment;
|
codeoffset := codeoffset - 1;
|
||||||
NSISFun := NSISFun - 1;
|
Result := g_extraparameters.exec_code_segment(codeoffset, g_hwndParent);
|
||||||
Result := func(NSISFun, g_hwndParent);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -156,8 +151,8 @@ begin
|
||||||
ItemCount := SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
ItemCount := SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
||||||
item.iItem := ItemCount;
|
item.iItem := ItemCount;
|
||||||
item.mask := LVIF_TEXT;
|
item.mask := LVIF_TEXT;
|
||||||
item.pszText := PAnsiChar(Msg);
|
item.pszText := PChar(Msg);
|
||||||
ListView_InsertItem(g_hwndList, item );
|
ListView_InsertItem(g_hwndList, item);
|
||||||
ListView_EnsureVisible(g_hwndList, ItemCount, TRUE);
|
ListView_EnsureVisible(g_hwndList, ItemCount, TRUE);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue