Archive: Problem sending string arg to DLL function


Problem sending string arg to DLL function
Hey all,
I need some assistant.
I'm calling a DLL function from an NSIS script. The function takes a char* as an argument. However, when I send a string to the DLL function, I only get the first char of the string.

Here's the call to the function:
Processes::KillParentProcess "chrome"

I get the string in the DLL by using popstring(char* str)

To debug, I used a message box and only got "c" instead of "chrome"

I'd really appreciate some input on this


I'm having the same issue....anybody have any advice? Popstring is returning only the first character from the string parameter.


Are you using Unicode NSIS with a non-unicode DLL or maybe vice-versa?

Some code would help too.

Stu


Unicode NSIS with Unicode RealProgress plugin.

From the call to plugin:
RealProgress::DetailProgress /NOUNLOAD 30 40

Debugging the plugin code...in the function

int popstring(TCHAR *str, int len)
{
stack_t *th;

if (!g_stacktop || !*g_stacktop) return 1;
th=(*g_stacktop);
lstrcpyn(str, th->text, len);
*g_stacktop=th->next;
GlobalFree((HGLOBAL)th);
return 0;
}

str is returning '3' (as opposed to '30') when called from the DetailProgress function...

extern "C"
void __declspec(dllexport) DetailProgress(HWND hWndParent, int string_size,
TCHAR *variables, stack_t **stacktop,
extra_parameters *extra)
{
g_hWndParent=hWndParent;

EXDLL_INIT();
{
TCHAR szParam[8];

// Attempt to get a parameter.
if (popstring(szParam, 8) == 0)
{

//szParam evaluated at this point is '3'
//MessageBox(hWndParent, szParam, "Add szParam", MB_OK);


// Get the number of details to be printed.
g_iProgressBarAdd = str2int(szParam);

.
.
etc.


Are you definitely using Unicode character set in the plug-in? Sounds to me like you aren't because a Unicode '3' would be an ASCII '3' padded with a leading NULL byte thereby terminating the string as a single ASCII character.

Stu


I should probably elaborate a bit more:

* Check you have Unicode selected in Properties (that one is too obvious I know)
* Check you have since done a Clean/Rebuild
* Are you using the Unicode pluginapi.lib and header?

Stu


Yes. Unicode versions of all.


Well I'll need more than that. Attach the files including the vcxproj.

Stu


vcproj file can be found here


I said files including the vcproj. I can't build without all the files.

Stu


Plugin files can be found below:

RealProgress.cpp
RealProgress.vcproj
RealProgress.dsp
RealProgress.sln


I can't see any reference to the Unicode plug-in API in there. You should really use that. For an example, look at my Aero plug-in which has both ANSI and Unicode plug-in APIs bundled and a build configuration for each. Also if you use the plug-in API you get myatoi and myatou so you don't need to use CRT (which you want to avoid).

Stu