Пример #1
0
        private RegistryKey GetUninstallerRegistryKey(ProgramInfo objProgramInfo, bool blnCreateIfNotFound = false)
        {
            RegistryKey appKey;
            RegistryKey softwareKey;

            softwareKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true);

            if (softwareKey == null)
            {
                Globals.Logger.LogError("HKLM\\Software registry key not found.", true, true);
            }

            string guidText = objProgramInfo.GetUninstallerGuidAsString();

            appKey = softwareKey.OpenSubKey(guidText, true) ?? softwareKey.CreateSubKey(guidText);

            if (appKey == null)
            {
                Globals.Throw(String.Format("Unable to create uninstaller {0}", guidText));
            }

            if (softwareKey != null)
            {
                softwareKey.Close();
            }

            return(appKey);
        }
Пример #2
0
        private void RemoveInstallerRegistryKeys(ProgramInfo objProgramInfo)
        {
            RegistryKey softwareKey;

            string guidText = objProgramInfo.GetUninstallerGuidAsString();

            softwareKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true);

            if (softwareKey == null)
            {
                Globals.Logger.LogError("HKLM\\Software registry key not found.");
                return;
            }

            softwareKey.DeleteSubKeyTree(guidText, false);

            if (softwareKey != null)
            {
                softwareKey.Close();
            }
        }