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

Problem using ANSI tring for folder path in Installshield 2011

Hi ,

We have encountered an issue after we upgraded our Install Shield version to 2011 and migrated our project from 2009 to 2011. The issue description as below...

In Install shield project we have an option that the user can choose to install to a different path than the default path. In the script we have a method to change the installation path which intern calls a method written in Delphi. The Delphi method returns changed installation path as string which is assigned to a variable in Install Script defined as STRING and later assigned to INSTALLDIR and TARGETDIR. While Installing, after changing the installation path its displaying the changed path in junk characters.

can any one suggest regarding this issue. we are unaware of how to use the ANSI string returned from DLL(written in Delphi) in the install script as it is without converting it to unicode characters.

We also tried returning unicode(WidePChar) string from Delphi code but of no use.


Thanks,
Shijat.
Labels (1)
0 Kudos
(6) Replies
cydz1985
Level 3

Hi,

I'm having the same problem as yours when I tried to migrate to IS 2012 from IS 2010. DLL function returns garbage values in my InstallScript. I fixed it by converting my DLL to a unicode format.

For example:

instead of using LPCSTR for accepting strings I used LPCWSTR instead like below:

LPCWSTR function()
{
LPCWSTR msg= L"Hello World";
MessageBoxW(NULL,msg,L"Message",MB_OK);
return msg;
}
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I don't know quite enough about Delphi, but if it exports C-style functions, you just have to be careful to indicate whether you're passing an ANSI character string (or buffer) around, or a Unicode character string (or buffer). You do this in InstallScript by specifying STRING or WSTRING respectively in the extern prototype, and explicit suffixing of function names if you need SomeFunctionA instead of SomeFunctionW. If you haven't already done so, check out the information in the sticky of this forum, but it doesn't talk specifically about Delphi either.
0 Kudos
mshijat
Level 3

Thanks MichaelU & cydz1985 for quick reply.

we tried using unicode strings in Delphi code also, but didnt found any solution if any familiar with Delphi also Please provide some more information.


Thanks & Regards,
Shijat.
0 Kudos
mshijat
Level 3

Thanks cydz1985,

We changed all the Delphi code to support unicode and its working fine now.

Previously when we changed the code to support unicode didnt changed the Install script code from BYVAL STRING TO BYVAL WSTRING.

Now every thing is working fine.


Thanks,
Shijat.
0 Kudos
Techmaddy
Level 3

I am also facing the same situation using C++ dll.

Isn't there a solution other than converting the dll into unicode?
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

The answer to that depends on the problems you are trying to solve. If it's a matter of passing data between InstallScript and C++, you just need to ensure that your functions are declared correctly (extern prototype ... using STRING or WSTRING depending on your dll). If you need to support characters other than those available on your code page, you need to use Unicode strings and functions. Neither of these strictly require compiling your DLL as Unicode, but I would suggest doing so for the latter case.
0 Kudos