I've added some more features. Now you can not only check if something is installed, you can also check which version is installed. Also, you can get the
"UninstallString" key which can be used with
SHELL to uninstall the programs.
If IsInstalled
("teamviewer") Then Print CheckVersion
("teamviewer") Print GetUninstallString
("teamviewer")
If IsInstalled
("powershell 7-x64") Then Print CheckVersion
("powershell 7-x64") Print GetUninstallString
("powershell 7-x64")
If IsInstalled
("Google Chrome") Then Print CheckVersion
("Google Chrome") Print GetUninstallString
("Google Chrome") 'Shell GetUninstallString("Google Chrome")
Const HKEY_LOCAL_MACHINE
= &H80000002~&
Const KEY_ALL_ACCESS
= &HF003F&
Const KEY_READ
= &H20019&
sRoot
= "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" + Chr$(0)
If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sRoot
), 0, KEY_READ
, _Offset(hUninstKey
)) <> ERROR_SUCCESS
Then IsInstalled = 0
dwBufferSize
= Len(sAppKeyName
) lResult
= RegEnumKey
(hUninstKey
, dwindex
, _Offset(sAppKeyName
), _Offset(dwBufferSize
), 0, 0, 0, 0) If lResult
= ERROR_SUCCESS
Then If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sSubKey
), 0, KEY_READ
, _Offset(hAppKey
)) <> ERROR_SUCCESS
Then RegCloseKey hAppKey
RegCloseKey hUninstKey
IsInstalled = 0
dwBufferSize
= Len(sDisplayName
) RegCloseKey hAppKey
RegCloseKey hUninstKey
IsInstalled = -1
RegCloseKey hAppKey
dwindex = dwindex + 1
RegCloseKey hUninstKey
IsInstalled = IsInstalled64(software)
Const HKEY_LOCAL_MACHINE
= &H80000002~&
Const KEY_ALL_ACCESS
= &HF003F&
Const KEY_READ
= &H20019&
sRoot
= "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" + Chr$(0)
If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sRoot
), 0, KEY_READ
, _Offset(hUninstKey
)) <> ERROR_SUCCESS
Then IsInstalled64 = 0
dwBufferSize
= Len(sAppKeyName
) lResult
= RegEnumKey
(hUninstKey
, dwindex
, _Offset(sAppKeyName
), _Offset(dwBufferSize
), 0, 0, 0, 0) If lResult
= ERROR_SUCCESS
Then If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sSubKey
), 0, KEY_READ
, _Offset(hAppKey
)) <> ERROR_SUCCESS
Then RegCloseKey hAppKey
RegCloseKey hUninstKey
IsInstalled64 = 0
dwBufferSize
= Len(sDisplayName
) RegCloseKey hAppKey
RegCloseKey hUninstKey
IsInstalled64 = -1
RegCloseKey hAppKey
dwindex = dwindex + 1
RegCloseKey hUninstKey
IsInstalled64 = 0
Const HKEY_LOCAL_MACHINE
= &H80000002~&
Const KEY_ALL_ACCESS
= &HF003F&
Const KEY_READ
= &H20019&
sRoot
= "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" + Chr$(0)
If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sRoot
), 0, KEY_READ
, _Offset(hUninstKey
)) <> ERROR_SUCCESS
Then CheckVersion = ""
dwBufferSize
= Len(sAppKeyName
) lResult
= RegEnumKey
(hUninstKey
, dwindex
, _Offset(sAppKeyName
), _Offset(dwBufferSize
), 0, 0, 0, 0) If lResult
= ERROR_SUCCESS
Then If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sSubKey
), 0, KEY_READ
, _Offset(hAppKey
)) <> ERROR_SUCCESS
Then RegCloseKey hAppKey
RegCloseKey hUninstKey
CheckVersion = ""
dwBufferSize
= Len(sDisplayName
) CheckVersion
= Mid$(version
, 1, verlen
- 1) CheckVersion = ""
RegCloseKey hAppKey
RegCloseKey hUninstKey
RegCloseKey hAppKey
dwindex = dwindex + 1
RegCloseKey hUninstKey
CheckVersion = CheckVersion64(software)
Const HKEY_LOCAL_MACHINE
= &H80000002~&
Const KEY_ALL_ACCESS
= &HF003F&
Const KEY_READ
= &H20019&
sRoot
= "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" + Chr$(0)
If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sRoot
), 0, KEY_READ
, _Offset(hUninstKey
)) <> ERROR_SUCCESS
Then CheckVersion64 = ""
dwBufferSize
= Len(sAppKeyName
) lResult
= RegEnumKey
(hUninstKey
, dwindex
, _Offset(sAppKeyName
), _Offset(dwBufferSize
), 0, 0, 0, 0) If lResult
= ERROR_SUCCESS
Then If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sSubKey
), 0, KEY_READ
, _Offset(hAppKey
)) <> ERROR_SUCCESS
Then RegCloseKey hAppKey
RegCloseKey hUninstKey
CheckVersion64 = ""
dwBufferSize
= Len(sDisplayName
) CheckVersion64
= Mid$(version
, 1, verlen
- 1) CheckVersion64 = ""
RegCloseKey hAppKey
RegCloseKey hUninstKey
RegCloseKey hAppKey
dwindex = dwindex + 1
RegCloseKey hUninstKey
CheckVersion64 = ""
Const HKEY_LOCAL_MACHINE
= &H80000002~&
Const KEY_ALL_ACCESS
= &HF003F&
Const KEY_READ
= &H20019&
sRoot
= "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" + Chr$(0)
If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sRoot
), 0, KEY_READ
, _Offset(hUninstKey
)) <> ERROR_SUCCESS
Then GetUninstallString = ""
dwBufferSize
= Len(sAppKeyName
) lResult
= RegEnumKey
(hUninstKey
, dwindex
, _Offset(sAppKeyName
), _Offset(dwBufferSize
), 0, 0, 0, 0) If lResult
= ERROR_SUCCESS
Then If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sSubKey
), 0, KEY_READ
, _Offset(hAppKey
)) <> ERROR_SUCCESS
Then RegCloseKey hAppKey
RegCloseKey hUninstKey
GetUninstallString = ""
dwBufferSize
= Len(sDisplayName
) GetUninstallString
= Mid$(uninstall
, 1, Lenuninstall
- 1) GetUninstallString = ""
RegCloseKey hAppKey
RegCloseKey hUninstKey
RegCloseKey hAppKey
dwindex = dwindex + 1
RegCloseKey hUninstKey
GetUninstallString = GetUninstallString64(software)
Const HKEY_LOCAL_MACHINE
= &H80000002~&
Const KEY_ALL_ACCESS
= &HF003F&
Const KEY_READ
= &H20019&
sRoot
= "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" + Chr$(0)
If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sRoot
), 0, KEY_READ
, _Offset(hUninstKey
)) <> ERROR_SUCCESS
Then GetUninstallString64 = ""
dwBufferSize
= Len(sAppKeyName
) lResult
= RegEnumKey
(hUninstKey
, dwindex
, _Offset(sAppKeyName
), _Offset(dwBufferSize
), 0, 0, 0, 0) If lResult
= ERROR_SUCCESS
Then If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sSubKey
), 0, KEY_READ
, _Offset(hAppKey
)) <> ERROR_SUCCESS
Then RegCloseKey hAppKey
RegCloseKey hUninstKey
GetUninstallString64 = ""
dwBufferSize
= Len(sDisplayName
) GetUninstallString64
= Mid$(uninstall
, 1, Lenuninstall
- 1) GetUninstallString64 = ""
RegCloseKey hAppKey
RegCloseKey hUninstKey
RegCloseKey hAppKey
dwindex = dwindex + 1
RegCloseKey hUninstKey
GetUninstallString64 = ""
Sub EnumInstalledPrograms
Const HKEY_LOCAL_MACHINE
= &H80000002~&
Const KEY_ALL_ACCESS
= &HF003F&
Const KEY_READ
= &H20019&
sRoot
= "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" + Chr$(0)
If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sRoot
), 0, KEY_READ
, _Offset(hUninstKey
)) <> ERROR_SUCCESS
Then dwBufferSize
= Len(sAppKeyName
) lResult
= RegEnumKey
(hUninstKey
, dwindex
, _Offset(sAppKeyName
), _Offset(dwBufferSize
), 0, 0, 0, 0) If lResult
= ERROR_SUCCESS
Then If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sSubKey
), 0, KEY_READ
, _Offset(hAppKey
)) <> ERROR_SUCCESS
Then RegCloseKey hAppKey
RegCloseKey hUninstKey
dwBufferSize
= Len(sDisplayName
) RegCloseKey hAppKey
dwindex = dwindex + 1
RegCloseKey hUninstKey
EnumInstalledPrograms64
Sub EnumInstalledPrograms64
Const HKEY_LOCAL_MACHINE
= &H80000002~&
Const KEY_ALL_ACCESS
= &HF003F&
Const KEY_READ
= &H20019&
sRoot
= "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" + Chr$(0)
If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sRoot
), 0, KEY_READ
, _Offset(hUninstKey
)) <> ERROR_SUCCESS
Then dwBufferSize
= Len(sAppKeyName
) lResult
= RegEnumKey
(hUninstKey
, dwindex
, _Offset(sAppKeyName
), _Offset(dwBufferSize
), 0, 0, 0, 0) If lResult
= ERROR_SUCCESS
Then If RegOpenKey
(HKEY_LOCAL_MACHINE
, _Offset(sSubKey
), 0, KEY_READ
, _Offset(hAppKey
)) <> ERROR_SUCCESS
Then RegCloseKey hAppKey
RegCloseKey hUninstKey
dwBufferSize
= Len(sDisplayName
) RegCloseKey hAppKey
dwindex = dwindex + 1
RegCloseKey hUninstKey