Exemple #1
0
        private void get_elements_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            //Add item to listView
            object[]    item_info = e.UserState as object[];
            IntPtr      data      = (IntPtr)item_info[0];
            App_add     item      = (App_add)item_info[1];
            ImageSource image     = Imaging.CreateBitmapSourceFromHBitmap(data, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            item.ImageData = image;
            listView.Items.Add(item);
            programs_count.Content = apps_count + " apps were found";
        }
Exemple #2
0
 private void textBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     listView_Copy.Visibility = Visibility.Visible;
     listView_Copy.Items.Clear();
     if (textBox.Text == "")
     {
         listView_Copy.Visibility = Visibility.Hidden;
     }
     else
     {
         for (int i = 0; i < listView.Items.Count; i++)
         {
             App_add app = listView.Items[i] as App_add;
             if (app.Title.ToLower().Contains(textBox.Text.ToLower()))
             {
                 listView_Copy.Items.Add(app);
             }
         }
     }
 }
Exemple #3
0
        private void unistall_Click(object sender, RoutedEventArgs e)
        {
            uninstall.IsEnabled = false;
            App_add          selected_item = (App_add)listView.SelectedItem;
            MessageBoxResult res           = MessageBox.Show("You are sure that you want to uninstall the program?", "Uninstall Manager", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                var process = new ProcessStartInfo()
                {
                    UseShellExecute  = true,
                    WorkingDirectory = @"C:\Windows\System32",
                    FileName         = @"C:\Windows\System32\cmd.exe",
                    Arguments        = "/c " + '"' + Uninstall_paths[listView.SelectedIndex] + '"',
                    WindowStyle      = ProcessWindowStyle.Hidden
                };
                Process.Start(process).WaitForExit();
                Uninstall_paths.RemoveAt(listView.SelectedIndex);
                listView.Items.RemoveAt(listView.SelectedIndex);
            }
            listView_Copy.Visibility = Visibility.Hidden;
            textBox.Text             = "";
        }
Exemple #4
0
        private void get_elements_DoWork(object sender, DoWorkEventArgs e)
        {
            void get_apps(RegistryKey OpenBaseKey)
            {
                string[] programs = OpenBaseKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall").GetSubKeyNames();
                foreach (string app in programs)
                {
                    string unistallstring = (string)OpenBaseKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + app).GetValue("UninstallString");
                    if (unistallstring != null || unistallstring != "")
                    {
                        try
                        {
                            RegistryKey path            = OpenBaseKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + app);
                            string      displayname     = (string)path.GetValue("DisplayName");
                            string      InstallLocation = (string)path.GetValue("InstallLocation");
                            if (displayname == null || displayname == "")
                            {
                                displayname = "Unknown";
                            }
                            string publisher = (string)path.GetValue("Publisher");
                            if (publisher == null || publisher == "")
                            {
                                publisher = "Unknown";
                            }
                            string displayicon = (string)path.GetValue("DisplayIcon");
                            if (displayicon == null)
                            {
                                displayicon = @"C:\Windows\system32\ComputerDefaults.exe";
                            }
                            string icon_path = displayicon.Split(',')[0];
                            displayicon = displayicon.ToLower().Replace('"', ' ').Trim();
                            IntPtr data;
                            if (!unistallstring.ToLower().Contains("msiexec"))
                            {
                                data = System.Drawing.Icon.ExtractAssociatedIcon(icon_path).ToBitmap().GetHbitmap();
                            }
                            else
                            {
                                data = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\Windows\system32\ComputerDefaults.exe").ToBitmap().GetHbitmap();
                            }
                            App_add item = new App_add()
                            {
                                Title = displayname, Provider = publisher
                            };
                            object[] item_info = new object[2];
                            item_info[0] = data;
                            item_info[1] = item;
                            get_elements.ReportProgress(0, item_info);
                            Uninstall_paths.Add(unistallstring);
                            apps_count++;
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }
            }

            get_apps(RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32)); //Getting applications for x32 from HKLM
            get_apps(RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, RegistryView.Registry32));  //Getting applications for x32 from HKCU
            if (Environment.Is64BitOperatingSystem)
            {
                get_apps(RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64));//Getting applications for x64 from HKLM
            }
        }