It is required in the Inno Setup script to get the version of the product already installed by ProductUpgradeCode and display it.
You can get product id by ProductUpgradeCode using MsiEnumRelatedProducts .
Next, the product version can be using MsiGetProductInfo .
#ifdef UNICODE #define AW "W" #else #define AW "A" #endif const ERROR_SUCCESS = $00000000; ERROR_NOT_ENOUGH_MEMORY = $00000008; ERROR_INVALID_PARAMETER = $00000057; ERROR_NO_MORE_ITEMS = $00000103; ERROR_BAD_CONFIGURATION = $0000064A; function MsiEnumRelatedProducts(lpUpgradeCode: string; dwReserved: DWORD; iProductIndex: DWORD; lpProductBuf: string): UINT; external 'MsiEnumRelatedProducts{#AW}@msi.dll stdcall'; function MsiGetProductInfo(szProduct: string; szProperty: string; lpValueBuf: string; pcchValueBuf: DWORD): UINT; external 'MsiGetProductInfo{#AW}@msi.dll stdcall'; function CheckPreviousProductInstance(upgradeCode: string; var previousVersion: string): Boolean; var i: Integer; productBuf: string; versionBuf: string; pcchValueBuf: DWORD; resultCode: UINT; begin Result := True; i := 0; SetLength(productBuf, 39); if MsiEnumRelatedProducts(upgradeCode, 0, i, productBuf) <> ERROR_SUCCESS then begin result := false; exit; end; MsgBox(productBuf, mbInformation, MB_OK); resultCode := MsiGetProductInfo(productBuf, 'INSTALLPROPERTY_VERSIONSTRING', versionBuf, pcchValueBuf); MsgBox(IntToStr(Integer(resultCode)), mbInformation, MB_OK); if MsiGetProductInfo(productBuf, 'INSTALLPROPERTY_VERSIONSTRING', versionBuf, pcchValueBuf) <> ERROR_SUCCESS then begin result := false; exit; end; MsgBox(versionBuf, mbInformation, MB_OK); MsgBox(IntToStr(Integer(pcchValueBuf)), mbInformation, MB_OK); result := true; end; MsiGetProductInfo returns $ 0000648.
How to do right?