
svend_lysemose asked a question.
MsiGetProperty
nLEN must now be assigned before calling MsiGetProperty in InstallScript

svend_lysemose asked a question.
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Activity: Status change: 2 hours ago
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Revenera Assistant
Try this direct link:
http://kb.flexerasoftware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=Q211163
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.
Both Chrome and Firefox can display KB articles, so they may be other options to consider.
Short of a really good explanation, I would describe this change as a bug not an improvement.