展开全部
这种东西其实在百度搜一下或者去MSDN上直接查就能够查得到的。
下面是代码。编译环境vs2010。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace GetInstalledSoftwareLIst
{
class Program
{
static void Main(string[] args)
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall", false))
{
if (key != null)//判断对象存在
{
foreach (string keyName in key.GetSubKeyNames())//遍历子项名称的字符串数组
{
using (RegistryKey key2 = key.OpenSubKey(keyName, false))//遍历子项节点
{
if (key2 != null)
{
string softwareName = key2.GetValue("DisplayName", "").ToString();//获取软件名
string installLocation = key2.GetValue("InstallLocation", "").ToString();//获取安装路径
if (!string.IsNullOrEmpty(installLocation))
{
Console.WriteLine(softwareName+"\t"+installLocation);
}
}
}
}
}
}
Console.ReadLine();
}
}
}
下面是代码。编译环境vs2010。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace GetInstalledSoftwareLIst
{
class Program
{
static void Main(string[] args)
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall", false))
{
if (key != null)//判断对象存在
{
foreach (string keyName in key.GetSubKeyNames())//遍历子项名称的字符串数组
{
using (RegistryKey key2 = key.OpenSubKey(keyName, false))//遍历子项节点
{
if (key2 != null)
{
string softwareName = key2.GetValue("DisplayName", "").ToString();//获取软件名
string installLocation = key2.GetValue("InstallLocation", "").ToString();//获取安装路径
if (!string.IsNullOrEmpty(installLocation))
{
Console.WriteLine(softwareName+"\t"+installLocation);
}
}
}
}
}
}
Console.ReadLine();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询