从Windows程序列表WPF中运行程序 [英] Run a program from windows program list WPF

查看:81
本文介绍了从Windows程序列表WPF中运行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想从列表中运行特定的已安装程序.

我有程序的名称,但没有安装路径.

我还有一个列表,其中包含计算机上所有已安装的程序.

有什么办法可以直接从该列表中运行程序吗?

我已使用以下代码获取已安装程序的列表.

Hi All,

I want to run a specific installed program from my list.

I have the name of the program but not the installed path of it.

I also have a list which contains all the installed programs on my computer.

Is there any way to run a program directly from that list?

I have used following code to get list of installed programs.

using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
 foreach (string skName in rk.GetSubKeyNames())
 {
 using (RegistryKey sk = rk.OpenSubKey(skName))      
{                                               
 if (!(sk.GetValue("DisplayName") == null))
  {  lstProgramList.Add(sk.GetValue("DisplayName").ToString());
  }
  }
 }
 }

推荐答案

好,您可以通过枚举抛出安装程序列表并在内部循环中尝试在您的名称"中找到其DisplayName来做到这一点.列表".可以使用System.Collections.Generic.Dictionary快速搜索而不是列表.

但是,没有可靠的方法来基于此名称标识程序.该名称不能唯一地标识该程序,因此,两个程序原则上可以具有相同的名称.没有人关心它,因为几乎不需要它.我不知道你为什么需要这样的东西.对我来说,它闻起来可怜的建筑,没有更多了.
—SA
OK, you can do it by enumerating throw the installing program list and in inner loop trying to find its DisplayName in your "name list". Instead of list you can use System.Collections.Generic.Dictionary for fast search.

However, there is no reliable way to identify a program based on this name. The name does not uniquely identify the program, so two programs can have the same name, in principle. Nobody cares about it because it is hardly required. I have no idea why do you require such thing. It smells poor architecture to me, no more…

—SA


这篇关于从Windows程序列表WPF中运行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆