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
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
uses
|
||||
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
|
||||
// set up global variables
|
||||
Init(hwndParent, string_size, variables, stacktop);
|
||||
|
@ -25,7 +49,46 @@ begin
|
|||
SetUserVariable(INST_0, 'This is user var $0');
|
||||
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
|
||||
end.
|
||||
|
|
|
@ -52,12 +52,12 @@ type
|
|||
|
||||
type
|
||||
PluginCallbackMessages = (
|
||||
NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
|
||||
NSPIM_GUIUNLOAD, // Called after .onGUIEnd
|
||||
NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
|
||||
NSPIM_GUIUNLOAD // Called after .onGUIEnd
|
||||
);
|
||||
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;
|
||||
Tvalidate_filename = procedure (const filename: PChar); stdcall;
|
||||
|
@ -84,7 +84,7 @@ type
|
|||
pextrap_t = ^extrap_t;
|
||||
extrap_t = record
|
||||
exec_flags: Pointer; // exec_flags_t;
|
||||
exec_code_segment: Pointer; // TFarProc;
|
||||
exec_code_segment: TExecuteCodeSegment; // TFarProc;
|
||||
validate_filename: Pointer; // Tvalidate_filename;
|
||||
RegisterPluginCallback: Pointer; //TRegisterPluginCallback;
|
||||
end;
|
||||
|
@ -102,10 +102,7 @@ var
|
|||
g_hwndParent: HWND;
|
||||
g_hwndList: HWND;
|
||||
g_hwndLogList: HWND;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -125,23 +122,21 @@ begin
|
|||
g_hwndParent := hwndParent;
|
||||
g_stacktop := stacktop;
|
||||
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;
|
||||
extrap := g_extraparameters^;
|
||||
end;
|
||||
|
||||
|
||||
function Call(NSIS_func : String) : Integer;
|
||||
var
|
||||
NSISFun: Integer; //The ID of nsis function
|
||||
codeoffset: Integer; //The ID of nsis function
|
||||
begin
|
||||
Result := 0;
|
||||
NSISFun := StrToIntDef(NSIS_func, 0);
|
||||
if (NSISFun <> 0) and (g_extraparameters <> nil) then
|
||||
codeoffset := StrToIntDef(NSIS_func, 0);
|
||||
if (codeoffset <> 0) and (g_extraparameters <> nil) then
|
||||
begin
|
||||
@func := extrap.exec_code_segment;
|
||||
NSISFun := NSISFun - 1;
|
||||
Result := func(NSISFun, g_hwndParent);
|
||||
codeoffset := codeoffset - 1;
|
||||
Result := g_extraparameters.exec_code_segment(codeoffset, g_hwndParent);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -156,8 +151,8 @@ begin
|
|||
ItemCount := SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
||||
item.iItem := ItemCount;
|
||||
item.mask := LVIF_TEXT;
|
||||
item.pszText := PAnsiChar(Msg);
|
||||
ListView_InsertItem(g_hwndList, item );
|
||||
item.pszText := PChar(Msg);
|
||||
ListView_InsertItem(g_hwndList, item);
|
||||
ListView_EnsureVisible(g_hwndList, ItemCount, TRUE);
|
||||
end;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue