ManageApps:C#读取Windows系统中的已经安装的程序并卸载软件
2012-09-25 15:54
211 查看
可以使用C#来操作注册表来获取当前Windows系统中的已经安装的软件或程序,当然,也可以用来卸载软件了。
【网通】点击这里下载全部源程序 【电信、网通】点击这里下载源程序
【下载说明】
1、单击上面这个地址,打开下载页面。
2、点普通下载--等待30秒--点“下载”按钮--保存
![](http://img.my.csdn.net/uploads/201209/25/1348559751_5801.jpg)
![](http://img.my.csdn.net/uploads/201209/25/1348559754_5135.jpg)
主要源程序:
【更多阅读】
[原]使用Excel的VBA来读取和修改bmp位图像素数据
[原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
[原]《The C Programming Language》电子书下载
[原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
[原]GetAlpha:C#实现获取网页验证码图片,并识别出其中的字母
[原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
[译]C#控制计算机的并口LPT
[译]在C# .NET2.0实现单实例应用程序
[译]在C# .NET2.0实现单实例应用程序
[译]C#控制计算机的并口LPT
【网通】点击这里下载全部源程序 【电信、网通】点击这里下载源程序
【下载说明】
1、单击上面这个地址,打开下载页面。
2、点普通下载--等待30秒--点“下载”按钮--保存
![](http://img.my.csdn.net/uploads/201209/25/1348559751_5801.jpg)
![](http://img.my.csdn.net/uploads/201209/25/1348559754_5135.jpg)
主要源程序:
/* * Created by SharpDevelop. * User: PJ * Date: 2012-7-13 * Time: 15:20 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Windows.Forms; using Microsoft.Win32; namespace ManageApps { /// <summary> /// Description of MainForm. /// </summary> public partial class MainForm : Form { private List<string> apps=new List<string>(); public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // LoadApps(); } void LoadApps() { string tempType = null; object displayName = null, uninstallString = null,releaseType = null; RegistryKey currentKey = null; int softNum = 0; RegistryKey pregkey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall"); try { listBox1.Items.Clear(); apps.Clear(); foreach(string item in pregkey.GetSubKeyNames()) { currentKey = pregkey.OpenSubKey(item); displayName = currentKey.GetValue("DisplayName"); uninstallString = currentKey.GetValue("UninstallString"); releaseType = currentKey.GetValue("ReleaseType"); bool isSecurityUpdate = false; if(releaseType != null) { tempType = releaseType.ToString(); if(tempType == "Security Update" || tempType == "Update") isSecurityUpdate = true; } if( !isSecurityUpdate && displayName != null && uninstallString != null) { listBox1.Items.Add(displayName.ToString()); apps.Add(displayName.ToString() + "," + uninstallString.ToString()); softNum++; label1.Text = softNum.ToString() + " Apps"; } } } catch(Exception e) { MessageBox.Show(e.Message.ToString(),"Exception"); } finally { pregkey.Close(); } } void RunDosCommand(string cmd) { Process p=new Process(); p.StartInfo.FileName="cmd.exe"; p.StartInfo.UseShellExecute=false; p.StartInfo.RedirectStandardInput=false; p.StartInfo.Arguments="/c "+cmd; p.StartInfo.RedirectStandardOutput=true; p.StartInfo.CreateNoWindow=true; p.Start(); p.WaitForExit(); p.Close(); } void BtnUninstallClick(object sender, EventArgs e) { int selectIndex = listBox1.SelectedIndex; string selectText = listBox1.Items[selectIndex].ToString(); string uninstallString = null; //MessageBox.Show(selectText); for(int i=0;i<apps.Count;i++) { if(apps[i].Split(',')[0] == selectText) { uninstallString = apps[i].Split(',')[1]; break; } } RunDosCommand(uninstallString); } void BtnRefreshClick(object sender, EventArgs e) { tbxFilter.Text=""; LoadApps(); } void TbxFilterTextChanged(object sender, EventArgs e) { string filterText = tbxFilter.Text.ToLower(); if(filterText.Trim() != "") { listBox1.Items.Clear(); for(int i=0;i<apps.Count;i++) { if(apps[i].Split(',')[0].ToLower().Contains(filterText)) { listBox1.Items.Add(apps[i].Split(',')[0]); } } } else LoadApps(); } } }
【更多阅读】
[原]使用Excel的VBA来读取和修改bmp位图像素数据
[原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
[原]《The C Programming Language》电子书下载
[原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
[原]GetAlpha:C#实现获取网页验证码图片,并识别出其中的字母
[原]ManageStartUpApps:C#操作注册表来读取和修改开机启动项
[译]C#控制计算机的并口LPT
[译]在C# .NET2.0实现单实例应用程序
[译]在C# .NET2.0实现单实例应用程序
[译]C#控制计算机的并口LPT
相关文章推荐
- C#Windows Service程序的创建安装与卸载
- C# 创建、安装和卸载Windows服务程序
- C#Windows Service服务程序的安装/卸载、启动/停止 桌面客户端管理程序设计
- C# 创建、安装和卸载Windows服务程序
- C:\Windows\system32\MSVCR100.dll 没有被指定在 Windows 上运行,或者它包含错误。请尝试使用原始安装媒体重新安装程序,或联系您的系统管理员或软件供应商以获取支持。【解决办法】
- C# Windows 服务 的简单程序的编写,安装 和 卸载
- C#软件winform程序安装包制作及卸载程序制作
- 在C#中如何获取系统中所安装的所有软件信息,还有如何打开系统中某个程序
- C#软件winform程序安装包制作及卸载程序制作
- C#软件winform程序安装包制作及卸载程序制作
- C#软件winform程序安装包制作及卸载程序制作
- C#软件winform程序安装包制作及卸载程序制作
- c# 安装和卸载Windows Service(程序)
- 32位QT程序读取64位系统的注册表中的64位安装软件
- C# 远程服务器 安装、卸载 Windows 服务,读取远程注册表,关闭杀掉远程进程
- C# 远程服务器 安装、卸载 Windows 服务,读取远程注册表,关闭杀掉远程进程
- windows系统卸载程序不彻底,系统服务中有残留如何删除
- (转载整理)程序安装流程及如何实现文件在系统后自动重启(windows)
- 使用Android系统隐藏api 读取*.apk 程序安装包信息[转]
- 手把手教你用C#打包应用程序(安装程序)【卸载模块已添加】