cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
SlimSuky
Level 3

Install Script STRING -> C++ DLL using UNICODE data

Hello,

I'm using Install Shield 2009 and have an Install Shield Install Script project to take in user entered data and pass that off to a C++ DLL to do some processing.

The STRING data type is defined as two-byte UNICODE data and I have my C++ DLL expecting two-byte UNICODE data - however if I enter in regular text 'hello' or Asian characters (on an Asian OS) I always seem to get unibyte data handed off to the C++ DLL.

I can not find a setting that specifies that encoding type of the Install Shield project, yet am at a loss to explain why I don't get two byte data representation of the user entered data.

Has anyone experienced this or can shed some guidance on what I may be doing wrong?

Thanks.
Labels (1)
0 Kudos
(6) Replies
RobertDickau
Flexera Alumni

Perhaps see if the InstallScript WSTRING data type helps?
0 Kudos
SlimSuky
Level 3

RobertDickau wrote:
Perhaps see if the InstallScript WSTRING data type helps?


Works like a charm.

Thanks Robert.
0 Kudos
SlimSuky
Level 3

I'm now struggling with getting UNICODE data from the C++ DLL back to Install Script.

The C++ method is declared so that it returns back multi byte text:
extern "C" wchar_t* WINAPI GetText()
{
return L"Robert";
};

The Install Script prototype is:
prototype WSTRING MyDLL.GetText();

Usage:
WSTRING szMyString;
szMyString = GetText();

However szMyString always only has 'R' as a value. Interchanging STRING for WSTRING appears not to make a difference. As well, using TCHAR* in place of wchar_t* also makes no difference (which is expected).

If I create another method in the C++ DLL which returns back CHAR * - no problems, I get "Robert" back to the Install Script member. But I would have expected that since I'm using WSTRING which is expecting two bytes per character and the C++ is returning L"" which is also two bytes per character that it should have worked.

How does one return double-byte strings from a DLL into Install Script variables?

:confused:
0 Kudos
RobertDickau
Flexera Alumni

Does it work if you return the value in place, using BYREF WSTRING on the InstallScript side of the prototype?
0 Kudos
neelx1
Level 2

Even I have similar kinda problem...
I am using BYREF but it does not seems to be working...
Please let me know what solution you people have got..
0 Kudos
RobertDickau
Flexera Alumni

Code like this in the DLL---
void __stdcall returnUnicodeInPlace(wchar_t* ws)
{
wsprintf(ws, L"Something");
return;
}
---and this in InstallScript---
prototype void ReturnUnicodeToInstallScript.returnUnicodeInPlace(BYREF WSTRING);

function OnBegin( )
WSTRING w;
begin

UseDLL(SUPPORTDIR ^ "ReturnUnicodeToInstallScript.dll");

returnUnicodeInPlace(w);

MessageBox(w, INFORMATION);

UnUseDLL("ReturnUnicodeToInstallScript.dll");

end;

---seems to work in an InstallScript project...
0 Kudos