适用于Windows Applicaiton的C#安装项目 - 默认位置 [英] C# Setup Project for Windows Applicaiton - Default Location

查看:72
本文介绍了适用于Windows Applicaiton的C#安装项目 - 默认位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者。我最近在C#中开发了一个应用程序。现在我想开发它的设置。我想以编程方式更改程序的默认位置,我的意思是我想将默认位置设置为以前安装在客户端计算机上的程序的位置。但是我不知道这个其他程序的安装路径是什么,所以我必须在自定义操作的注册表中以编程方式找到它,但是在安装目录已经设置之前我无法启动自定义操作到默认值。



有人可以帮我吗?

I'm a beginner. I have recently developed an application in C#. Now I wanna develop its setup. I would like to change programmatically the Default Location of the program, I mean that I would like to set the default location to the location of a program previously installed on the client machine. However I don't know what is the installation path of this other program, so I have to find it programmatically in the registry with a custom action, but I'm not able to launch a custom action before the Installation dir has been already set to the default one.

Is there someone that could help me?

推荐答案

查找程序安装路径的理想方法是从注册表中读取它。安装者通常为包含其安装路径的程序创建一个注册表项。



要查找程序是否在注册表中有密钥,打开regedit.exe并使用编辑,在查找选项之后尝试找到包含程序名称的密钥。如果存在这样的密钥,您可以使用.NET Framework库中的RegistryKey类来读取它。



如果程序没有注册表项,那么另一个选项是只是要求用户使用OpenFileDialog找到.exe文件,虽然这显然不太理想。



希望这会有所帮助,请标记为答案。
The ideal way to find a program's installation path is to read it from the registry.Installers usually create a registry key for programs that contains their installation path.

To find if the program has a key in the registry, open "regedit.exe" and use the Edit , after that 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.

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.

Hope that will help, Please mark as answer.


希望这个线程能解决您面临的自定义操作问题

link [ ^ ]
Hope this thread will solve the custom action problem you are facing
link[^]


这篇关于适用于Windows Applicaiton的C#安装项目 - 默认位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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