whossa
31st July 2012 07:31 UTC
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
Afrow UK
31st July 2012 11:03 UTC
Actually the full signature now is:
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
Anders
31st July 2012 14:35 UTC
Originally posted by Afrow UK
Actually the full signature now is
You are missing a __cdecl in there...
Afrow UK
31st July 2012 14:42 UTC
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
Anders
31st July 2012 21:22 UTC
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.