Thank you, your code helped me to put together an ultimate function to check if an application is installed or not. No matter if 32bit or 64bit
This might be helpful to others.
; Search Registry and Fallback to WMI (slower)
; $is64bit = -1: search 32bit and 64bit
; $is64bit = 0: search 32bit only
; $is64bit = 1: search 64bit only
Func IsApplicationInstalled($appName, $is64bit = 0, $wmiFallback = 1)
If $is64bit = -1 Then
If IsApplicationInstalled($appName, 0, 0) = 1 Then
Return 1
EndIf
$is64bit = 1
EndIf
$regList = GetRegUninstallList($is64bit)
If $regList = -1 Then Return -1
For $key in $regList
if StringLower($key) = StringLower($appName) Then
Return 1
EndIf
Next
If $wmiFallback = 1 Then
$wmiList = GetWMIList()
If $wmiList = -1 Then Return -1
For $app in $wmiList
if StringLower($app) = StringLower($appName) Then
Return 1
EndIf
Next
EndIf
Return 0
EndFunc
Func GetRegUninstallList($use64bit = 0)
$sRegHive = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
If $use64bit = 1 Then
$sRegHive = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Uninstall"
EndIf
Local $aUninstall[0]
$i = 1
While 1
$sRegKey = RegEnumKey($sRegHive, $i)
If @error Then ExitLoop
_ArrayAdd($aUninstall, RegRead($sRegHive & "\" & $sRegKey, "DisplayName"))
$i += 1
WEnd
Return _ArrayUnique($aUninstall)
EndFunc
Func GetWMIList()
Local $aResult[0]
$sPC = @ComputerName
$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sPC & "\root\cimv2")
$colProducts = $oWMI.ExecQuery("SELECT * FROM Win32_Product")
If IsObj($colProducts) Then
For $product in $colProducts
_ArrayAdd($aResult, $product.Caption)
Next
Return _ArrayUnique($aResult)
EndIf
Return -1
EndFunc