cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tier_3
Level 4

GetComputerName returns only the first character of the hostname in IS 2011

My existing project uses the GetComputerName function. After upgrading to IS 2011, only the first character of the hostname is returned.
I also tried the following code on a new project on both IS 2010 and 2011.


prototype BOOL KERNEL32.GetComputerName(BYREF STRING, BYREF NUMBER);

function OnBegin()
STRING szCmpName;
NUMBER nLength;
begin

//Using Win32 API
nLength = MAX_PATH;
GetComputerName(szCmpName, nLength);
MessageBox(szCmpName, INFORMATION);

end;



IS 2010 returns the full hostname.
IS 2011 returns the first character for the hostname.
Labels (1)
0 Kudos
(3) Replies
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

The prototype for this API is not specifying which thunk should be used (ANSI or Unicode). Therefore, the engine is defaulting to the Unicode version due to the Unicode changes made for IS 2011. Because the prototype is also using STRING parameters (i.e. ANSI strings), there is an mismatch here between the API and the parameter types. The prototype should be changed to specify which thunk to call (GetComputerNameA for ANSI or GetComputerNameW for Unicode) and the string parameter types should match (STRING for ANSI string parameters, WSTRING for Unicode string parameters).

Please see the "Q208911: Upgrading Projects to InstallShield 2011" article for more information.
0 Kudos
tier_3
Level 4

Thanks for the information. I will make the nescessary changes as suggested.
0 Kudos
theafterglow
Level 2

Thanks, this was a mystery to me also!!!
0 Kudos