Archive: Passing string parameter to a dll (a plugin actually)


Passing string parameter to a dll (a plugin actually)
Hi .
I am trying to pass a string argument to a dll(plugin) and then trying to write the same to a text file.
This is declaration in the header file of my dll

DECLDIR void writeToFile(char *str);

and following is the function definition in a cpp file.

void __declspec(dllexport) writeToFile(TCHAR data[])
{
}
When i run it through the nsi file ;i get "An unhandled win32 exception in the application"

Kindly help me sort this out.
This is quite urgent.


when you say plugin, do you mean NSIS plugin (if so, exported functions have a specific format, checkout the source for one of the plugins that ship with nsis)

if not, you must use the system plugin, something like:
system::call 'yourplugin::writeToFile(t "foo")'

(if your export is not stdcall(i would guess yours is cdecl), you must use the "?c" option (read the system readme))


Anders,
By dll i mean a sample NSIS plugin i created using Microsoft Visual C++ 2005.
I am just not able to pass the string to the dll i created.
Is there any way to access the string in my dll.
i tried collecting the string into a char * variable,but it didn't work.


When you say an NSIS plug-in, have you based it on exdll? You'd have to use popstring().

Stu


i don't understand by "based on exdll".
sorry for being a novice.
i made a dll using Microsoft Visual C++ 2005 dll creation wizard.
It contains a .h file and a .cpp file in place.
then i made a dll out of it.
i am able to make function calls which does not involve passing of parameters.
but i am not able to access a string that i pass to a LPWSTR variable or a char* variable.

Regards,
Giriraj


To use dll as nsis plugins you need to get the exdll header and see the function creation protocal in order to use with nsis...Grab the nsis source code @ main page and look @ Contrib\exdll


It's also available in Examples\Plugin when you install the NSIS package.


i had a look at the example in Examples\Plugin but i wasn't able to decipher it.
i followed the process as explained in the sample project in Examples\Plugin.
but i couldn't retrieve the parameter i passed.
I mean isn't there a simple way to pass a string to a dll and retrieve it.


Yes like I said, in NSIS use MyPlugin::Function "hello" then in the plug-in use:

char *param = (char*)LocalAlloc(LPTR, string_size);
popstring(param);
...
// param == "hello"
LocalFree(param);

Stu