IsCurrentPackageUpdatabled() public static method

public static IsCurrentPackageUpdatabled ( System.Version pkgVer ) : bool
pkgVer System.Version
return bool
Esempio n. 1
0
        public static CheckResult CheckNSISUninstallString(string RegistryPath, string MementoSection)
        {
            RegistryKey key    = null;
            CheckResult result = new CheckResult();

            result.state = CheckState.NOT_INSTALLED;

            try
            {
                key = OpenSubKey(Registry.LocalMachine, ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegistryPath), false,
                                 eRegWow64Options.KEY_WOW64_32KEY);
            }
            catch
            {
                // Parent key not open, exception found at opening (probably related to
                // security permissions requested)
            }
            if (key == null)
            {
                key =
                    Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegistryPath);
            }
            if (key != null)
            {
                int _IsInstalled = (int)key.GetValue(MementoSection, 0);
                int major        = (int)key.GetValue("VersionMajor", 0);
                int minor        = (int)key.GetValue("VersionMinor", 0);
                int revision     = (int)key.GetValue("VersionRevision", 0);
                key.Close();

                Version ver = new Version(major, minor, revision);

#if DEBUG
                MessageBox.Show("Registry version = <" + ver + ">, IsUpdatable= " + IsPackageUpdatabled(ver) + ", IsInstalled=" + _IsInstalled,
                                "Debug information: " + MementoSection, MessageBoxButtons.OK, MessageBoxIcon.Warning);
#endif

                if (_IsInstalled == 1)
                {
                    if (UpgradeDlg.reInstallForce)
                    {
                        result.state = Utils.IsCurrentPackageUpdatabled(ver) ? CheckState.VERSION_MISMATCH : CheckState.INSTALLED;
                    }
                    else if (UpgradeDlg.freshForce)
                    {
                        result.state = CheckState.VERSION_MISMATCH;
                    }
                    else
                    {
                        result.state = IsPackageUpdatabled(ver) ? CheckState.VERSION_MISMATCH : CheckState.INSTALLED;
                    }
                }
                else
                {
                    result.state = CheckState.NOT_INSTALLED;
                }
            }
            return(result);
        }
Esempio n. 2
0
        public static CheckResult CheckNSISUninstallString(string RegistryPath, string MementoSection)
        {
            CheckResult result = new CheckResult();

            result.state = CheckState.NOT_INSTALLED;

            RegistryKey key =
                Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegistryPath);

            if (key != null)
            {
                int _IsInstalled = (int)key.GetValue(MementoSection, 0);
                int major        = (int)key.GetValue("VersionMajor", 0);
                int minor        = (int)key.GetValue("VersionMinor", 0);
                int revision     = (int)key.GetValue("VersionRevision", 0);
                key.Close();

                Version ver = new Version(major, minor, revision);

#if DEBUG
                MessageBox.Show("Registry version = <" + ver + ">, IsUpdatable= " + IsPackageUpdatabled(ver) + ", IsInstalled=" + _IsInstalled,
                                "Debug information: " + MementoSection, MessageBoxButtons.OK, MessageBoxIcon.Warning);
#endif

                if (_IsInstalled == 1)
                {
                    if (UpgradeDlg.reInstallForce)
                    {
                        result.state = Utils.IsCurrentPackageUpdatabled(ver) ? CheckState.VERSION_MISMATCH : CheckState.INSTALLED;
                    }
                    else if (UpgradeDlg.freshForce)
                    {
                        result.state = CheckState.VERSION_MISMATCH;
                    }
                    else
                    {
                        result.state = IsPackageUpdatabled(ver) ? CheckState.VERSION_MISMATCH : CheckState.INSTALLED;
                    }
                }
                else
                {
                    result.state = CheckState.NOT_INSTALLED;
                }
            }
            return(result);
        }