This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- MsiGetProperty
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
‎Aug 26, 2011
01:51 PM
MsiGetProperty
nLEN must now be assigned before calling MsiGetProperty in InstallScript
(8) Replies
‎Sep 08, 2011
04:17 PM
Thanks for pointing that out. This change in behavior is now explained in KB article Q211163 (Upgrading Projects to InstallShield 2012). See the "Changes in Behavior for Some MSI APIs That Are Called in InstallScript Custom Actions" section of this article for more background.
‎Oct 03, 2011
02:23 AM
When I try to open Q211163 I get a blank page (I am succesfully logged in to the support portal).
‎Oct 03, 2011
08:24 AM
Hmm. That's weird. You should be able to see that KB article regardless of whether you are logged in. The URL that I provided above is a redirect URL. It seems to be working now, but maybe it wasn't redirecting for some reason when you tried it, or maybe your browser is blocking the redirect somehow.
Try this direct link:
http://kb.flexerasoftware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=Q211163
Try this direct link:
http://kb.flexerasoftware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=Q211163
‎Oct 03, 2011
08:52 AM
I have tried again from two different machines and can still not access Q211163. I am running Internet Explorer 9.0 and have no idea what could be causing the problem.
‎Oct 03, 2011
09:03 AM
Hmm. I'm not sure what's going on. I'll have someone look into it. In the meantime, here's the applicable content from the KB article:
Changes in Behavior for Some MSI APIs That Are Called in InstallScript Custom Actions
A change was made to how the InstallScript engine calls Windows Installer API such as MsiGetProperty. The engine now calls the Windows Installer APIs directly instead of using wrapper APIs that in turn call the Windows Installer APIs. This change was made to resolve issues with buffer handling and buffer sizes. It applies to all new projects that you create in InstallShield 2012, as well as projects that you have upgraded from earlier versions of InstallShield to InstallShield 2012.
As a result of this change, you can use the MSI install handle that is passed to a custom action function with all Windows Installer APIs that require an install handle. Previously, the handle was managed by the InstallScript engine, and it could not be passed directly to Windows Installer APIs.
Also as a result of this change, any Windows Installer APIs that require a buffer size to be specified now fail if the buffer size is not correctly specified. Note that 0 is not a valid size; thus, ensure that your code does not pass a zero value for the size of the buffer.
If you have existing InstallScript custom actions that call Windows Installer APIs, ensure that a large enough buffer size is specified; if it is not, unexpected results could occur.
The following sample code demonstrates how to retrieve the value of a Windows Installer property value string in InstallScript and increase the size of the buffer if necessary.
Note that if the script had used if ( ERROR_MORE_DATA == nResult ) then instead of if ( ERROR_MORE_DATA == nResult ) then, unexpected results could occur.
Changes in Behavior for Some MSI APIs That Are Called in InstallScript Custom Actions
A change was made to how the InstallScript engine calls Windows Installer API such as MsiGetProperty. The engine now calls the Windows Installer APIs directly instead of using wrapper APIs that in turn call the Windows Installer APIs. This change was made to resolve issues with buffer handling and buffer sizes. It applies to all new projects that you create in InstallShield 2012, as well as projects that you have upgraded from earlier versions of InstallShield to InstallShield 2012.
As a result of this change, you can use the MSI install handle that is passed to a custom action function with all Windows Installer APIs that require an install handle. Previously, the handle was managed by the InstallScript engine, and it could not be passed directly to Windows Installer APIs.
Also as a result of this change, any Windows Installer APIs that require a buffer size to be specified now fail if the buffer size is not correctly specified. Note that 0 is not a valid size; thus, ensure that your code does not pass a zero value for the size of the buffer.
If you have existing InstallScript custom actions that call Windows Installer APIs, ensure that a large enough buffer size is specified; if it is not, unexpected results could occur.
The following sample code demonstrates how to retrieve the value of a Windows Installer property value string in InstallScript and increase the size of the buffer if necessary.
prototype STRING MyGetProperty (HWND, STRING);
////////////////////////////////////////////////////////////////////////////////////////////
// MyGetProperty
// Return an MSI property string value
// Input Parameters:
// hMSIHandle: Handle to the currently running MSI database
// szPropertyName: Name of property to retrieve
// Output:
// String containing the property value
///////////////////////////////////////////////////////////////////////////////////////////
function STRING MyGetProperty (hMSIHandle, szPropertyName)
NUMBER nvBuf, nResult;
STRING szReturn;
begin
//Retrieve the size of the property value szReturn = "";
nResult = MsiGetProperty (hMSIHandle, szPropertyName, szReturn, nvBuf);
if (ERROR_MORE_DATA == nResult) then
nvBuf = nvBuf + 1; //increment buffer size for terminating null
//Retrieve the property value
nResult = MsiGetProperty (hMSIHandle, szPropertyName, szReturn, nvBuf);
if (nResult != ERROR_SUCCESS) then
szReturn = "";
endif;
endif;
return szReturn;
end;
Note that if the script had used if ( ERROR_MORE_DATA == nResult ) then instead of if ( ERROR_MORE_DATA == nResult ) then, unexpected results could occur.
‎Feb 13, 2012
03:27 PM
Can someone at InstallShield explain the rational for why this change was made? While I understand how the MSI API works in a C/C++ world, InstallScript is supposed to be a higher level language and we've always ( 13 years? ) been able to make this API calls without having to do silly things like set nBufferSize since InstallScript doesn't require you to size string buffers in the first place. ( Well, atleast not since InstallShield 3 as I recall... )
Short of a really good explanation, I would describe this change as a bug not an improvement.
Short of a really good explanation, I would describe this change as a bug not an improvement.
‎Feb 14, 2012
08:31 AM
It's both. Previously you didn't really have to set nBufferSize because we ignored it and used a relatively high value. However this means when you legitimately had a really long property value, it couldn't be read. The "fix" for the latter part broke the first part. Personally I think there's a better middle ground to be found, perhaps use the larger of the previous value and the passed value.