Old 21st December 2017, 13:44   #1
sfx09
Junior Member
 
Join Date: Jul 2017
Posts: 27
NSIS plugin via Delphi (codeoffset for function)

Hello!

I need to create plugin for NSIS installer using Delphi. I can't use C/C++, because some of the code is already Delphi-written in secondary project. I used manual - NSIS\Examples\Plugin\nsis.pas. Can someone explain me this part of implementation code?

PHP Code:
function Call(NSIS_func String) : Integer;
var
  
codeoffsetInteger//The ID of nsis function
begin
  Result 
:= 0;
  
codeoffset := StrToIntDef(NSIS_func0);
  if (
codeoffset <> 0) and (g_extraparameters <> nilthen
    begin
    codeoffset 
:= codeoffset 1;
    
Result := g_extraparameters.exec_code_segment(codeoffsetg_hwndParent);
    
end;
end
For example, I call this function: NSIS_Call('MyBestFunctionInScript').
But, "MyBestFunctionInScript" (value of "codeoffset") will be converted at 0 always (why StrToIntDef?). Maybe need to remove StrToIntDef on other function?

In C-example I find this interface (maybe it's normal working convertion string function name at codeoffset):

PHP Code:
INT_PTR NSISCALL nsishelper_str_to_ptr(LPCTSTR s);
#define myatoi(s) ( (int) nsishelper_str_to_ptr(s) ) // converts a string to an integer 
But, I can't find an implementation. Can anyone help me? Big thanks.
sfx09 is offline   Reply With Quote
Old 22nd December 2017, 14:18   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,814
Call does not take the string name of a NSIS function.

The NSIS code needs to call GetFunctionAddress and pass the returned value to your plugin function (and it is passed as a string). Your plugin function then uses this string with Call().

nsishelper_str_to_ptr is just a internal StrToInt style function used by C plug-ins.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd December 2017, 22:42   #3
sfx09
Junior Member
 
Join Date: Jul 2017
Posts: 27
Thumbs up

thanks! all worked now. =) my eyes are a little blind
sfx09 is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump