Microsoft Installer MSI HasRelatedProduct Macro: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(Initial Release) |
(Renamed Macro per discussion in Talk page,) |
||
Line 7: | Line 7: | ||
## if an msi package on the same upgrade track as the provided GUID is | ## if an msi package on the same upgrade track as the provided GUID is | ||
## installed. | ## installed. | ||
${If} ${ | ${If} ${MSI_HasRelatedProduct} `{D8968392-698B-4A41-B6AD-C25C6608A69B}` | ||
DetailPrint "A | DetailPrint "A product is installed on the same track." | ||
${Else} | ${Else} | ||
DetailPrint "No | DetailPrint "No product track is installed matching the the supplied GUID." | ||
${EndIf}</highlight-nsis> | ${EndIf}</highlight-nsis> | ||
== Macro == | == Macro == | ||
<highlight-nsis>!include "LogicLib.nsh" | <highlight-nsis>!include "LogicLib.nsh" | ||
!define | !define MSI_HasRelatedProduct `"" MSI_HasRelatedProduct` | ||
!macro | !macro _MSI_HasRelatedProduct _a _b _t _f | ||
!insertmacro _LOGICLIB_TEMP | !insertmacro _LOGICLIB_TEMP | ||
System::Call `Msi::MsiEnumRelatedProducts(&t39 '${_b}',i 0,i 0,&t39 n)i .s` | System::Call `Msi::MsiEnumRelatedProducts(&t39 '${_b}',i 0,i 0,&t39 n)i .s` |
Revision as of 21:53, 20 April 2011
Author: Zinthose (talk, contrib) |
About
Short and simple macro to extend LogicLib to allow for testing the system for MSI packages that are installed with the same UpgradeCode as provided.
Example
## This example uses the MsiEnumRelatedProducts MSI API call to determine ## if an msi package on the same upgrade track as the provided GUID is ## installed. ${If} ${MSI_HasRelatedProduct} `{D8968392-698B-4A41-B6AD-C25C6608A69B}` DetailPrint "A product is installed on the same track." ${Else} DetailPrint "No product track is installed matching the the supplied GUID." ${EndIf}
Macro
!include "LogicLib.nsh" !define MSI_HasRelatedProduct `"" MSI_HasRelatedProduct` !macro _MSI_HasRelatedProduct _a _b _t _f !insertmacro _LOGICLIB_TEMP System::Call `Msi::MsiEnumRelatedProducts(&t39 '${_b}',i 0,i 0,&t39 n)i .s` Pop $_LOGICLIB_TEMP !insertmacro _== $_LOGICLIB_TEMP 0 `${_t}` `${_f}` !macroend
Issues
- Only tested on XP x86
- Requires Microsoft Installer to be previously installed. If it isn't then it's likely that no MSI packages are installed anyway ;-)