Exemplo n.º 1
0
        public Version GetInstalledVersion()
        {
            var products = MsiApi.GetRelatedProducts(UpgradeCode);

            if (products.Count == 0)
            {
                // is it possible and should we worry?
                return(new Version("0.0.0"));
            }
            // can the products count be > 1 and how should we get the right one?
            else if (!Version.TryParse(products[0].Version, out var version))
            {
                // is it possible and what should we do?
                return(new Version("0.0.0"));
            }
            else
            {
                return(version);
            }
        }
Exemplo n.º 2
0
        public bool VerifyPackage(string packagePath)
        {
            if (!MsiApi.VerifyPackage(packagePath))
            {
                return(false);
            }

            var package = new MsiPackage(packagePath);

            if (!Guid.TryParse(package.UpgradeCode, out var upgradeCode))
            {
                // is it possible and what should we do?
                return(false);
            }

            if (upgradeCode != UpgradeCode)
            {
                return(false);
            }

            // TODO: implement verification by signature
            return(true);
        }