private void RemoveProgramFromRegistry() { if (this.listViewProgs.SelectedItems.Count > 0) { ListViewItem lvi = this.listViewProgs.SelectedItems[0]; Common_Tools.ProgramInfo progInfo = lvi.Tag as Common_Tools.ProgramInfo; if (MessageBox.Show(this, Properties.Resources.umForceUninstall, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { progInfo.RemoveFromRegistry(); } PopulateListView(); } }
private void listViewProgs_SelectedIndexChanged(object sender, EventArgs e) { if (this.listViewProgs.SelectedItems.Count > 0) { ListViewItem lvi = this.listViewProgs.SelectedItems[0]; Common_Tools.ProgramInfo progInfo = lvi.Tag as Common_Tools.ProgramInfo; this.buttonUninstall.Enabled = progInfo.Uninstallable; this.buttonRemove.Enabled = true; } else { // Disable buttons if nothing selected this.buttonUninstall.Enabled = false; this.buttonRemove.Enabled = false; } }
private void UninstallProgram() { if (this.listViewProgs.SelectedItems.Count > 0) { ListViewItem lvi = this.listViewProgs.SelectedItems[0]; Common_Tools.ProgramInfo progInfo = lvi.Tag as Common_Tools.ProgramInfo; if (progInfo.InstallLocation == System.IO.Directory.GetCurrentDirectory()) { MessageBox.Show(this, Properties.Resources.umCannotUninstall, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show(this, Properties.Resources.umUninstall, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { progInfo.Uninstall(); } PopulateListView(); } }
/// <summary> /// Verifies installed programs in add/remove list /// </summary> public static void Scan() { try { Main.Logger.WriteLine("Verifying programs in Add/Remove list"); using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")) { if (regKey == null) { return; } foreach (string strProgName in regKey.GetSubKeyNames()) { using (RegistryKey regKey2 = regKey.OpenSubKey(strProgName)) { if (regKey2 != null) { ScanDlg.CurrentScannedObject = regKey2.ToString(); Common_Tools.ProgramInfo progInfo = new Common_Tools.ProgramInfo(regKey2); if (regKey2.ValueCount <= 0) { ScanDlg.StoreInvalidKey(Strings.InvalidRegKey, regKey2.ToString()); continue; } if (progInfo.WindowsInstaller) { continue; } if (string.IsNullOrEmpty(progInfo.DisplayName) && (!progInfo.Uninstallable)) { ScanDlg.StoreInvalidKey(Strings.InvalidRegKey, regKey2.ToString()); continue; } // Check display icon if (!string.IsNullOrEmpty(progInfo.DisplayIcon)) { if (!Utils.IconExists(progInfo.DisplayIcon)) { ScanDlg.StoreInvalidKey(Strings.InvalidFile, regKey2.ToString(), "DisplayIcon"); } } // Check install location if (!string.IsNullOrEmpty(progInfo.InstallLocation)) { if ((!Utils.DirExists(progInfo.InstallLocation)) && (!Utils.FileExists(progInfo.InstallLocation))) { ScanDlg.StoreInvalidKey(Strings.InvalidFile, regKey2.ToString(), "InstallLocation"); } } // Check install source if (!string.IsNullOrEmpty(progInfo.InstallSource)) { if ((!Utils.DirExists(progInfo.InstallSource)) && (!Utils.FileExists(progInfo.InstallSource))) { ScanDlg.StoreInvalidKey(Strings.InvalidFile, regKey2.ToString(), "InstallSource"); } } // Check ARP Cache if (progInfo.SlowCache) { if (!string.IsNullOrEmpty(progInfo.FileName)) { if (!Utils.FileExists(progInfo.FileName)) { ScanDlg.StoreInvalidKey(Strings.InvalidRegKey, progInfo.SlowInfoCacheRegKey); } } } } } } } Main.Logger.WriteLine("Verifying registry entries in Add/Remove Cache"); checkARPCache(Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\")); checkARPCache(Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\")); } catch (System.Security.SecurityException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }