c# 如何获得你电脑安装的所有程序信息
2010-08-07 14:57
330 查看
我们知道程序安装后,在注册表里的 SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall 都会有记录.因此,我们利用这个记录就可以浏览我们电脑上安装的所有软件信息了. 代码实现如下:
private string Getinstalledsoftware()
{
string Software = null;
//The registry key:
string SoftwareKey = @"SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
if (!(sk.GetValue("DisplayName") == null))
{
if (sk.GetValue("InstallLocation") == null)
Software += sk.GetValue("DisplayName") + " - 路径未知/n"; //Nope, not here.
else
Software += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "/n"; //Yes, here it is...
}
}
catch (Exception ex)
{
}
}
}
}
return Software;
}
//EXAMPLE USAGE:
private void get_software_list_button__Click(object sender, RoutedEventArgs e)
{
//MessageBox.Show(Getinstalledsoftware());
this.textBox1.Text = Getinstalledsoftware();
}
源码下载地址: http://www.dengfeng.org/soft/AppShortcut.zip
private string Getinstalledsoftware()
{
string Software = null;
//The registry key:
string SoftwareKey = @"SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
if (!(sk.GetValue("DisplayName") == null))
{
if (sk.GetValue("InstallLocation") == null)
Software += sk.GetValue("DisplayName") + " - 路径未知/n"; //Nope, not here.
else
Software += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "/n"; //Yes, here it is...
}
}
catch (Exception ex)
{
}
}
}
}
return Software;
}
//EXAMPLE USAGE:
private void get_software_list_button__Click(object sender, RoutedEventArgs e)
{
//MessageBox.Show(Getinstalledsoftware());
this.textBox1.Text = Getinstalledsoftware();
}
源码下载地址: http://www.dengfeng.org/soft/AppShortcut.zip
相关文章推荐
- 在C#中如何获取系统中所安装的所有软件信息,还有如何打开系统中某个程序
- 获得系统中所有安装程序的信息
- 如何在没有安装.NET Framework的电脑上运行C#程序
- 获得所有已安装程序的信息
- 如何用C#获得文件信息以及扩展信息
- 如何用C#获得文件信息以及扩展信息
- Day2 如何在没有安装halcon软件的电脑上运行halcon编写的程序
- 整理PackageManager,获取所有安装程序信息
- 如何获得数据库里所有表的名字(SQL+C#)
- asp.net+C# 服务器安装篇---分析器错误信息: 未能加载程序集 app_Web _**** 请确保在访问该页之前已经编译了此程序
- (C#)如何用.NET的安装项目打包程序?
- C# 如何用DragDrop拖放特殊文件到程序窗口 (如:我的电脑 回收站 网上邻居)
- 在Linux下如何在程序中获得当前调用栈信息
- opencv和vs 编译生成的程序如何运行在没有安装的电脑上
- 获得电脑的信息 控制台程序
- 得到安卓所有已安装程序的信息
- 如何获得数据库里所有表的名字(SQL+C#)
- c#下如何生成安装程序
- C# Setup项目 如何修改默认程序目录(安装路径)
- 如何使编译的ROM能使所有程序获得root权限执行