Archive: Function for Checking MSI version


Function for Checking MSI version
Hi,

I am currently testing NSIS, and since the best way to test it (in my opinion) is to try and dublicate the functionality of our existing installer (InstallShield *shakes and twists*), I have to come up with various "new" functions.

As I discover a way to do these, I'd like to contribute those that may be useful to others, and as I don't have any idea on how to use WIKI, I'll post them here.

This is the first snippet which I think others may have a use for.

It is a method for checking the version of the currently installed Windows Installer (MSI). This is necessary for e.g. installing the Sql Express 2005.

The version the function is checking against is 3.1, but it should be fairly simple to change it to check against an abitrary version.


;*********************************************************************
; UpdateMSIVersion
;
; This function will check the version of the installed Windows
; Installer. This is done by checking the version of the
; $SYSDIR\MSI.dll (recommended method by the installer team).
;
; Usage
; Call UpdateMSIVersion
; Pop $MSI_UPDATE ; If $MSI_UPDATE is 1, install latest MSI.
;*********************************************************************
Function UpdateMSIVersion
GetDllVersion "$SYSDIR\MSI.dll" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF

IntCmp $R2 3 0 InstallMSI RightMSI
IntCmp $R3 1 RightMSI InstallMSI RightMSI

RightMSI:
Push 0
Goto ExitFunction

InstallMSI:
MessageBox MB_OK|MB_ICONEXCLAMATION \
"Windows Installer 3.1 was not detected; this is required for installation. \
Setup will install the Windows Installer. This may take awhile, please wait."
Push 1
Goto ExitFunction

ExitFunction:

FunctionEnd


This function is heavily inspired by UpdateMDACVersion by Matthew Kershaw, so thank you to him.

I hope some of you may find a use for it.

According to wiki, you may want to check out this,

http://nsis.sourceforge.net/Starting_a_new_page


Cool! Don't know why I didn't find that link, but I'll be sure to check it out. Thanks.