I came across this question looking for an answer in the context of checking for the Visual C++ redistributable as part of an MSI installer created by WiX.
I didn't like how the GUID's change with version and operating system, so I ended up creating a custom action written in C# to check for the Visual C++ redistributable.
Everything below is specifically for Visual C++ 2015 Redistributable (x64), but it can be easily modified for any version.
using Microsoft.Deployment.WindowsInstaller;using Microsoft.Win32;namespace CustomActions{ public class DependencyChecks { [CustomAction] public static ActionResult IsVC2015RedistInstalled(Session session) { session.Log("Begin Visual C++ 2015 Redistributable installation check."); var dependenciesKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Classes\\Installer\\Dependencies"); foreach(var subKey in dependenciesKey.GetSubKeyNames()) { var dependency = dependenciesKey.OpenSubKey(subKey); var displayName = (string)dependency.GetValue("DisplayName"); if(displayName != null) { if (displayName.Contains("Microsoft Visual C++ 2015 Redistributable (x64)")) { session.Log("Visual C++ 2015 Redistributable is installed."); return ActionResult.Success; } } } session.Log("Visual C++ 2015 Redistributable is not installed."); session.Message(InstallMessage.Error, new Record(1, "This application requires Visual C++ 2015 Redistributable. Please install, then run this installer again. https://www.microsoft.com/en-us/download/details.aspx?id=53587")); return ActionResult.Failure; } }}
Then in the wxs file
<Binary Id='VC2015RedistCheck' SourceFile='!(wix.ResourcesDir=resources)\CustomActions.CA.dll'/><CustomAction Id='VC2015RedistCheckAction' Execute='immediate' BinaryKey='VC2015RedistCheck' DllEntry="IsVC2015RedistInstalled" Return='check'/><InstallExecuteSequence><Custom Action='VC2015RedistCheckAction' After='InstallInitialize'/></InstallExecuteSequence>
EditI'm updating this answer with some basic info on creating and using a custom action.
To create the custom action in Visual Studio 2017 with the WiX Toolset Visual Studio 2017 extension installed, I used the project template to create a custom action (C# Custom Action Project for WiX v3).
I checked the generated project and it seemed to already have the changes listed at the beginning of this article: https://www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed so I picked that article up at the section Adding Custom Action to the Installer
and followed it through with some tweaks.
One other thing that I did was change the version of the .NET framework the project is built against to 3.5.
I didn't find it really useful but you can also see http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html