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
- :
- Can't programmatically get ProductVersion
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
‎Feb 16, 2011
08:49 AM
Can't programmatically get ProductVersion
I need to get the product version of the current build but these attempts don't work
szBuild = @ProductVersion
or
MsiGetProperty(ISMSI_HANDLE, "ProductVersion", szBuild, nSize);
Actually, I'm not even sure why I use the ISMSI_HANDLE parameter. I think I saw it in an example somewhere.
How do I get this property which is set on the property sheet for the build.
I can get the product name without a problem.
szBuild = @ProductVersion
or
MsiGetProperty(ISMSI_HANDLE, "ProductVersion", szBuild, nSize);
Actually, I'm not even sure why I use the ISMSI_HANDLE parameter. I think I saw it in an example somewhere.
How do I get this property which is set on the property sheet for the build.
I can get the product name without a problem.
(6) Replies
‎Feb 16, 2011
01:52 PM
For an MSI project, you should be able to get the value of ProductVersion (or any other property) in the usual places. (You'll need to go through CustomActionData if you're getting the value during deferred mode, for example.)
The help topic "ISMSI_HANDLE" describes where and why to use that in MSI function calls.
The help topic "ISMSI_HANDLE" describes where and why to use that in MSI function calls.
‎Feb 16, 2011
08:03 PM
I don't know what you mean by "usual places". I thought the two ways I tried were the usual places.
Can you give the exact way to get the Version number? The help file doesn't show an example and it's different from how to get the Product Name which would appear to be a similar type of property.
Can you give the exact way to get the Version number? The help file doesn't show an example and it's different from how to get the Product Name which would appear to be a similar type of property.
‎Feb 16, 2011
08:41 PM
The @Something format is just for string-table entries. The MsiGetProperty technique does the trick in more places (for MSI properties, of course), and for event handlers such as OnBegin, the "ISMSI_HANDLE" help topic has an example.
For InstallScript custom actions (where you prototype "export prototype something(HWND); ... function something(hMSI)..."), the InstallShield help topic "Getting and Setting Properties" has a similar example.
For InstallScript custom actions (where you prototype "export prototype something(HWND); ... function something(hMSI)..."), the InstallShield help topic "Getting and Setting Properties" has a similar example.
‎Feb 17, 2011
01:02 PM
I'm really sorry for bothering you and feel like a complete idiot but for whatever reason, I can't seem to get the version property.
I have this code in OnBegin:
STRING svBuild[256];
NUMBER nSize;
....
MsiGetProperty(ISMSI_HANDLE, "PRODUCTVERSION", svBuild, nSize);
but svBuild is always blank.
I spelled the property name as "ProductVersion" and also ALL CAPS, and it didn't make a difference.
What am I missing?
Sorry for being so stupid, but can you give me the actual code? What I entered above and originally is what I thought the help file suggested.
I have this code in OnBegin:
STRING svBuild[256];
NUMBER nSize;
....
MsiGetProperty(ISMSI_HANDLE, "PRODUCTVERSION", svBuild, nSize);
but svBuild is always blank.
I spelled the property name as "ProductVersion" and also ALL CAPS, and it didn't make a difference.
What am I missing?
Sorry for being so stupid, but can you give me the actual code? What I entered above and originally is what I thought the help file suggested.
‎Feb 17, 2011
01:23 PM
Case does matter (ProductVersion, not PRODUCTVERSION, for example), so perhaps try this in an InstallScript MSI project:
Part of the trick is to make sure the nSize value is large enough to hold the largest value that could come back. We should really follow the idiom of calling MsiGetProperty once to get the buffer size (it'll return ERROR_MORE_DATA the first time), and then call it again to fill in the buffer; but common practice seems to be to lead in with an nSize value that would hold any string we expect to get back and call MsiGetProperty only once.
function OnBegin( )
STRING sProductVersion;
NUMBER nSize;
begin
nSize = 256;
MsiGetProperty(ISMSI_HANDLE, "ProductVersion", sProductVersion, nSize);
MessageBox("ProductVersion = " + sProductVersion, INFORMATION);
end;
Part of the trick is to make sure the nSize value is large enough to hold the largest value that could come back. We should really follow the idiom of calling MsiGetProperty once to get the buffer size (it'll return ERROR_MORE_DATA the first time), and then call it again to fill in the buffer; but common practice seems to be to lead in with an nSize value that would hold any string we expect to get back and call MsiGetProperty only once.
‎Feb 18, 2011
08:50 AM
Thanks! It's now working.
I was missing the setting of the nSize parameter before calling the routine. Based on the definition of it being an inout parameter, I didn't realize it needed to be set in advance.
It'd be nice to have your example in the help file. Would have saved a lot of frustration.
Thank you very much!
I was missing the setting of the nSize parameter before calling the routine. Based on the definition of it being an inout parameter, I didn't realize it needed to be set in advance.
It'd be nice to have your example in the help file. Would have saved a lot of frustration.
Thank you very much!