View Single Post
Old 15th December 2012, 18:47   #1
joe131
Junior Member
 
Join Date: Jun 2006
Posts: 23
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..
StringCbPrintfW((STRSAFE_LPWSTR)lpszDebugMsg,
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?

Thanks!
joe131 is offline   Reply With Quote