0

I have code to retrieve the Major versions of a product. Declared a property as PRODVER_MAJOR = 2 Code is as follows:

function myfunction(hMSI)
    string svmajorversion;
    number nsize;
begin
    nsize = 256;
    MsiGetProperty (ISMSI_HANDLE, "PRODVER_MAJOR", svmajorversion, nsize);
    MessageBox ("MajorVersion:" +svmajorversion, INFORMATION);
end
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164

2 Answers2

0

The behavior depends on the scheduling of the action. If this is called from a deferred custom action, it cannot access most properties directly, and instead must retrieve data through the property CustomActionData which in turn must have been set up before calling the action.

In either case, I would recommend replacing the use of ISMSI_HANDLE (a generic global handle primarily useful during events) with hMSI (the handle specifically passed to this custom action).

Michael Urman
  • 15,737
  • 2
  • 28
  • 44
0

It might help to actually check the return value of MsiGetProperty function.

Return value ERROR_INVALID_HANDLE An invalid or inactive handle was supplied.

ERROR_INVALID_PARAMETER
An invalid parameter was passed to the function.

ERROR_MORE_DATA
The provided buffer was too small to hold the entire value.

ERROR_SUCCESS
The function succeeded.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100