Vytautas
17th February 2004 11:43 UTC
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
Joel
17th February 2004 15:23 UTC
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
Joost Verburg
17th February 2004 16:48 UTC
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.
Vytautas
17th February 2004 23:20 UTC
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
Joel
17th February 2004 23:50 UTC
HANDLE to string try sprintf ;)
Vytautas
18th February 2004 01:56 UTC
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
eccles
18th February 2004 13:34 UTC
For a smaller .DLL, use wsprintf.
To convert the other way, find and use my_atoi, as mentioned earlier.
kichik
20th February 2004 11:28 UTC
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.