使用Visual Studio安装程序项目设置InstallPath注册表项 [英] Set InstallPath registry key using Visual Studio Setup project
问题描述
我正在使用为Visual Studio安装项目设计的msi安装程序来部署我的应用程序.如何将注册表项设置为应用程序的安装路径?
I am deploying my application using an msi installer designed with a Visual Studio Setup Project. How do I set a registry key to the application's install path?
推荐答案
一种方法是在安装程序中创建自定义操作.在自定义操作上,您可以提供CustomActionData"/Path =" [TARGETDIR] *.在您的自定义操作代码中,您可以引用Context.Parameters [" Path]并接收.NET代码中从安装程序传递的安装路径.
One way to do this would be to create a custom action in your installer. On the custom action you could provide CustomActionData "/Path="[TARGETDIR]*". Within your custom action code you can reference Context.Parameters["Path"] and receive the installation path passed from the installer in your .NET code.
现在,自定义操作代码中包含[TARGETDIR],您可以继续使用Microsoft.Win32命名空间来设置注册表项.
Now that you have the [TARGETDIR] within your custom action code you can continue to use the Microsoft.Win32 namespace to set the registry key.
HTH-威尔
这篇关于使用Visual Studio安装程序项目设置InstallPath注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!