Archive: Plugin help needed


Plugin help needed
I'm working on a new plugin for NSIS and have a couple of questions.

First, is there a way to convert a handle into a string so it can be passed to NSIS and then back into a handle when needed? I'm using c/c++ to program this plugin.

Or alternatively is there a way to create a *global* variable that different instances of the dll can access, e.g. normal global vars don't work when you call the plugin the second time the variable is reinitialized.

And finally, this is not really important but would be usefull none the less, is there a way for the plugin itself to specify that it should not be unloaded and then maybe have a special function which unloads the dll.

Vytautas


okay, I'll try to help you:
convert a handle into a string. Yeah, Nsis only accept Strings (Char) to be used in popstring. When I need to input a number, I inputed like string, for example "512". Since "512" is a string, you can easy use it with popstring to use it in the code, then I use my_atoi function (you can get it in system plugin source code) to convert the string->number


I think he is talking about C. You should read a tutorial that explains you how to work with pointers. A single Google search will help.


I found the functions to pop/push integer to the stack in the system dll source code. :D

However I found the the definition of a HANDLE is a 'pointer to void' and not a 'pointer to int'. This does not make sence to me as a always assumed that void is just that 'nothing'. :weird:

So any ideas of what I should use to convert a HANDLE to int or string and then back again?

Vytautas


HANDLE to string try sprintf ;)


Thanks Lobo Lunar this line worked great

sprintf(sThread, "%u", hThread);
However how do I convert that value back into HANDLE when I pop it again later in another call to the plugin. Either from int or char?

Vytautas

For a smaller .DLL, use wsprintf.

To convert the other way, find and use my_atoi, as mentioned earlier.


It is possible to create global variables using shared DLL sections. There is an article on CodeProject I think.

To force the DLL not to unload, load it yourself again using LoadLibrary. You'll probably have to add some more code than that, but it should be possible with some research.