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
Old 17th December 2012, 18:11   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump