Archive: How to Call an NSIS Plugin from C/C++


How to Call an NSIS Plugin from C/C++
I'm writing a C++ class that provides an update-from-web ability. This class needs to download (via HTTP) an INI file that describes the update (latest version number, URL to the update program, etc.). The INI will point at an NSIS installer that should be downloaded and then run to perform the update.

I was originally planning on writing an installer that does nothing more than uses the NSISdl plugin just to obtain the INI file. However, it would be easier if the C++ class could just download the INI file without having to exec this small NSIS installer. (I hate to add extraneous programs/files to my app.)

I've looked at the NSISdl source and see the exported functions of "download" and "download_quiet" used by the plugin architecture. I'd like to call those functions directly from my C++ class.

Is there any sample C/C++ code available on how to directly call the NSISdl plugin, or other plugins? Is there anything I should know about calling an exported function inside an NSIS plugin DLL? For example, I realize they are "C" style functions and would require the correct declaration in my C++ app. Anything else?


You should be able to find the right information from the NSIS source code, as it has to call the plugins itself ;)

Vytautas


Yes, I know I could look at the NSIS source itself, but I was hoping for a small snippet of sample code so I don't have to dig through all of NSIS. I've yet to crack it open and would like to avoid it if possible. :)


Did you try dllImport?


I'm trying to call the NSIS plugin from "unmanaged" C++ code, so from what I read on that web page, I don't need to use dllImport. I just wanted to see some C/C++ sample code that creates the required NSIS "stack" structs and passes it to the plugin function entry point. In my case, the "download" function of NSISdl.dll, but I'll take any sample for any plugin (again, C/C++ sample).

So does anyone have a C/C++ sample that calls an entry point in an NSIS plugin that they can share with me?

BTW, I've quickly become a *big* fan of NSIS installer. I've used InstallShield for years and as soon as I saw the NSIS install Welcome screen that said "isn't huge and doesn't suck", like InstallShield does, I knew NSIS was the installer for me and it's been great so far!


Why don't you just port the NSISdl code into your app. I believe that that would be far simpler to implement than recreating the NSIS variable and stack structures.

Vytautas