예제 #1
0
        private static bool VerifyDevDiv(VcRedistInfo info, RegistryView bit)
        {
            var regVersion = $"{(int) info.Version}.0";

            using (var reg = OpenRegistry(bit)
                             .OpenSubKey($@"SOFTWARE\Microsoft\DevDiv\vc\Servicing\{regVersion}\RuntimeMinimum"))
            {
                if (reg != null && TryConfirm(reg, "Install"))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        private static bool VerifyVS(VcRedistInfo info, RegistryView bit)
        {
            var regVersion = $"{(int)info.Version}.0";

            using (var reg = OpenRegistry(RegistryView.Registry32) // must look up in 32-bit registry
                             .OpenSubKey($@"SOFTWARE\Microsoft\VisualStudio\{regVersion}\VC\Runtimes\" +
                                         (bit == RegistryView.Registry32 ? "x86" : "x64")))
            {
                if (reg != null && TryConfirm(reg, "Installed"))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
        private static bool VerifySystemFile(VcRedistInfo info, RegistryView bit)
        {
            switch (bit)
            {
            case RegistryView.Registry32:
            {
                var folder = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86);
                return(File.Exists(Path.Combine(folder, info.SystemFile)));
            }

            case RegistryView.Registry64:
            {
                var folder = Environment.GetFolderPath(Environment.SpecialFolder.System);
                return(File.Exists(Path.Combine(folder, info.SystemFile)));
            }

            // TODO: This would be 64-bit on 64-bit runtime, and 32-bit on 32-bit runtime :S
            case RegistryView.Default:
                throw new NotSupportedException(bit + " is not supported");

            default:
                throw new NotSupportedException(bit + " is not supported");
            }
        }
예제 #4
0
 private static bool CheckVcRedistInstalled(VcRedistInfo info, RegistryView bit = RegistryView.Registry32)
 => VerifyRegistry(info, bit) && VerifySystemFile(info, bit);
예제 #5
0
 private static bool VerifyRegistry(VcRedistInfo info, RegistryView bit) => VerifyDevDiv(info, bit) && VerifyVS(info, bit);