Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 31st July 2012, 07:31   #1
whossa
Junior Member
 
Join Date: Jul 2012
Posts: 5
Question Why the signature of NSIS plugin doesn't match the one in the script?

Hi all,
I'm new to NSIS, and try to wrapper the custom control written in C++ as a dll/plugin and call the related api from nsis script, however, i do notice that in the nsis example, the InstallOptions plugin which have a C++ signature just like

extern "C" void __declspec(dllexport) dialog(HWND hwndParent, int string_size,
char *variables, stack_t **stacktop)

however, it just called in a script(testlink.nsi) like
InstallOptions::dialog "$PLUGINSDIR\test.ini"

Why the signature doesn't match with their counterpart? What have happened in the NSIS source code underbeneath?

Thanks
whossa is offline   Reply With Quote
Old 31st July 2012, 11:03   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Actually the full signature now is:
code:
extern "C" void __declspec(dllexport) name(HWND hWndParent, int string_size, TCHAR* variables, stack_t** stacktop, extra_parameters* extra)
(backwards compatible). As for your question, the parameters you pass in the script are not passed as parameters to the plug-in function. Instead they are passed via the NSIS stack. You use popstring to grab them.

Have you had a look at the System plug-in? You can call normal DLLs with that; would save you converting your one to an NSIS plug-in.

Stu
Afrow UK is offline   Reply With Quote
Old 31st July 2012, 14:35   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
Quote:
Originally Posted by Afrow UK View Post
Actually the full signature now is
You are missing a __cdecl in there...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 31st July 2012, 14:42   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You probably know this already but __cdecl is the default calling convention so you don't have to specify it.

Edit: Unless using msbuild with /Gr or /Gz.

Stu
Afrow UK is offline   Reply With Quote
Old 31st July 2012, 21:22   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
Even if cdecl is the default it should still be a part of the signature when posted in public. IMHO stdcall produces smaller and faster code, everyone should be using it on Windows.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
custom, function, nsis, visual c++

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