如何检测项目的安装目录?

发布于 2024-10-21 00:23:18 字数 292 浏览 1 评论 0原文

我有一个 Visual Studio C# 项目,并且有一个安装程序,可以将文件安装到用户指定的任何目录中。我还有另一个带有本地化语言资源的安装程序,我希望将其安装在上述目录中。

谁能指出我在这方面的正确方向?我想我必须对注册表项做一些事情,但我不知道该怎么做。

编辑:作为记录,我找到了此页面:如何:使用注册表启动条件指定目标目录。我按照说明进行操作,它做了我想做的事。

I have a Visual studio C# project and I have an installer that installs the files into whatever directory the user specifies. I also have another installer with localized language resources and I want that to be installed in the aforementioned directory.

Can anyone point me in the right direction on this? I think I have to do something with registry keys but I don't know what to do.

Edit: For the record, I found this page: How to: Use a Registry Launch Condition to Specify a Target Directory. And I followed the instructions and it did what I wanted it to do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雨后彩虹 2024-10-28 00:23:18

通常,您将创建一个注册表子项和 HKEY_LOCAL_MACHINE\SOFTWARE\ 值,然后在第二个安装程序中读回该项以决定将其放置在何处。

类似于 HKLM\SOFTWARE\MyApplication

然后创建一个名为 InstallPath 的字符串值,并在那里写入第一个安装程序的路径。

根据您正在执行的操作,您可能需要查看 合并模块,用于使用一个 MSI 安装多个组件。

Typically, you would create a registry subkey and value of HKEY_LOCAL_MACHINE\SOFTWARE\ and then just read that key back in your second installer to decide where to put that.

Something like HKLM\SOFTWARE\MyApplication,

Then you make a string value called InstallPath and write the path from your first installer there.

Depending on what you're doing, you may want to have a look at merge modules for installing several components with one MSI.

贪恋 2024-10-28 00:23:18

你走在正确的轨道上。您的第一个安装程序会将其安装路径写入众所周知的注册表项。第二个安装程序将从该众所周知的密钥中读取路径,并将其 dll 放入适当的子文件夹中。

You are on the right track. Your first installer would write it's install path to a well known registry key. The second installer would read the path from that well known key and put it's dlls in the appropriate sub folders.

不甘平庸 2024-10-28 00:23:18

这是一种方法:

Assembly a = Assembly.GetExecutingAssembly();

string folder = System.IO.Path.GetDirectoryName(a.CodeBase);

Here is one way to go at it:

Assembly a = Assembly.GetExecutingAssembly();

string folder = System.IO.Path.GetDirectoryName(a.CodeBase);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文