Archive: Calling C++ class from NSIS


Calling C++ class from NSIS
I just want to know if there is any way to call a c++ class into our nsis script ?

Thanks.


The installer (.exe) part of NSIS and the system plugin are both written in plain C and even if they were not this would be problematic since you would be crossing a compiler boundary and the method calling convention might not match.

You can only call extern "C" exported functions in a dlll...


Yeah, you generally have to write "plain C" wrapper functions around your C++ class for this...

#inlcude "MyClass.h"

extern "C"
{
__declspec(dllexport) void my_wrapper_function(void)
{
CMyClass *instance = new CMyClass();
instance->doSomething();
delete instance;
}
}