Archive: Problem returning string in System::Call param

Problem returning string in System::Call param
Hi All,

I have a DLL that I call using:

System::Call "Srv::sU(t .r2) i.r0"

DetailPrint "Return value: $0"
DetailPrint "Debug param value: $2"

and I'm having trouble returning a string through the
parameter. I want to be able to return an error string
with the error code if something fails.

The DLL code is:

extern "C" int __declspec(dllexport) sU(LPTSTR lpszDebugMsg)

// Test error return..
sizeof(lpszDebugMsg), (STRSAFE_LPCWSTR)L"QueryInterface() %lx", hres);

But I only get the first one to three characters of the string
no matter what combinations I try. I usually see something like that when
you try to use %s with a wide string.

I've tried changing the param to use LPWSTR and also trying to use
StringCbPrintfA(), but no luck.

I realize I have to pass in a buffer, and I might not be using
the System::Call parameter correctly.

What do I need to change to get it to work?


sizeof(lpszDebugMsg) is 4 on x86, always! So you can get 3 char's or 1 wchar_t in there before it stops the string copy...