NSIS 已安装产品

发布于 2024-08-29 21:21:56 字数 190 浏览 8 评论 0原文

我创建的 nsis 设置有一些问题。我需要检查产品是否已安装,然后获取已安装产品的路径。这是因为我想构建一个“功能设置”,将一些其他组件安装到以前安装的文件夹中。有谁知道如何构建这个安装程序?如果功能设置能够开始安装并检查已安装产品的路径,那就太好了。检查完成后,路径应该(只读)位于“选择安装位置”下的“目标文件夹”中。

感谢您的帮助
布巴

I have some problem with my created nsis setup. I need to check if the product is already installed and then get the path to the already installed product. This is because I want to build a "Feature-Setup" that installs some other components into the previous installed folder. Does anyone know how to build this installer? It will be brilliant if the feature setup will start the installation and check the path of the installed product. After checking is done the path should be (read only) in "Destination Folder" under "Choose Install Location".

Thanks for any help
Buba

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

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

发布评论

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

评论(1

◇流星雨 2024-09-05 21:21:56

NSIS 不会自己在任何地方写入任何内容,因此除非您自己向 \SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall 或 Software\Yourcompany\Yourapp 添加条目,您几乎必须使用 FindFirst、FindNext 来搜索机器。 (丑陋)

如果你有注册表项,你可以使用InstallDirRegKey或普通的注册表函数:

!define MyRegKey "Software\MyCompany\MyApp"

InstallDirRegKey HKLM "${MyRegKey}" InstallDir

var LockDirPage

!include LogicLib.nsh
Function .onInit
${If} ${FileExists} "$instdir\MyApp.exe"
    StrCpy $LockDirPage 1
${EndIf}
FunctionEnd

Function dirshow
${If} $LockDirPage = 1
    FindWindow $0 "#32770" "" $HWNDPARENT
    GetDlgItem $1 $0 0x3FB
    EnableWindow $1 0
    GetDlgItem $1 $0 0x3E9
    EnableWindow $1 0
${EndIf}
FunctionEnd

page directory "" dirshow
page instfiles

Section
WriteRegStr HKLM "${MyRegKey}" InstallDir $instdir ;save location
SectionEnd

NSIS does not write anything anywhere on its own, so unless you added a entry to <HKLM/HKCU>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall or Software\Yourcompany\Yourapp on your own, you pretty much have to search the machine with FindFirst,FindNext. (Ugly)

If you have a registry entry, you can use InstallDirRegKey or the normal registry functions:

!define MyRegKey "Software\MyCompany\MyApp"

InstallDirRegKey HKLM "${MyRegKey}" InstallDir

var LockDirPage

!include LogicLib.nsh
Function .onInit
${If} ${FileExists} "$instdir\MyApp.exe"
    StrCpy $LockDirPage 1
${EndIf}
FunctionEnd

Function dirshow
${If} $LockDirPage = 1
    FindWindow $0 "#32770" "" $HWNDPARENT
    GetDlgItem $1 $0 0x3FB
    EnableWindow $1 0
    GetDlgItem $1 $0 0x3E9
    EnableWindow $1 0
${EndIf}
FunctionEnd

page directory "" dirshow
page instfiles

Section
WriteRegStr HKLM "${MyRegKey}" InstallDir $instdir ;save location
SectionEnd
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文