我怎样才能获得另一个应用程序的安装路径编程? [英] How can I get another application's installation path programmatically?

查看:129
本文介绍了我怎样才能获得另一个应用程序的安装路径编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道一个应用程序的安装路径。我知道它通常是在... \\ Program Files文件...但我猜有些人在不同的位置安装。我知道应用程序的名称。

I'd like to know where the installation path for an application is. I know it usually is in ...\Program Files... but I guess some people install it in different locations. I do know the name of the application.

感谢您。

推荐答案

要找到一个程序的安装路径(在Windows上)的理想方法是从注册表中读取它。大多数安装程序将创建一个包含安装路径该程序的注册表项。正是这个关键,并根据问题的程序是什么将被命名为变化而变化。

The ideal way to find a program's installation path (on Windows) is to read it from the registry. Most installers will create a registry key for that program that contains the installation path. Exactly where this key is and what it will be named varies depending on the program in question.

要找到,如果该程序在注册表中的一个关键,开放式注册表编辑器'并使用编辑>查找选项尝试并找到该程序名称的关键。如果这样的键存在,可以使用在该的RegistryKey 类阅读.NET框架库。

To find if the program has a key in the registry, open 'regedit' and use the Edit > Find option to try and locate a key with the program name. If such a key exists, you can read it using the RegistryKey class in the .NET Framework library.

如果程序没有一个注册表项,那么另外一种办法就是要求用户找到与打开文件对话框中的.exe文件,虽然这显然是不理想的。

If the program does not have a registry key then another option is just to ask the user to locate the .exe file with the OpenFileDialog, although this is obviously not ideal.

这篇关于我怎样才能获得另一个应用程序的安装路径编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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