为什么当我添加自定义 nsDialog 页面时,我的 NSIS 脚本似乎跳过了像 MUI_PAGE_INSTFILES 这样的安装页面?

如何解决为什么当我添加自定义 nsDialog 页面时,我的 NSIS 脚本似乎跳过了像 MUI_PAGE_INSTFILES 这样的安装页面?

这是我最新的 NSIS 安装脚本,它已经成长为一个野兽。

https://pastebin.com/eSABLLsi

我的问题是,如何将 HW_DATA_DIRHW_WORKSPACE_DIR 和可能的 %HEADWAVE_ROOT_DIR% 的所有部分放入一个页面?我猜我必须以某种方式使用 nsDialog。我的主管希望我这样做,因为有太多单独的安装页面,您必须不断点击和点击太多次才能完成安装。

我尝试了以下方法,但在函数中添加 nsDialog 就像 Page custom HeadwaveConfiguration 一样,似乎不太适合程序流程。这是我的代码修改:

Var headwaveConfigDialog
Var headwaveConfigDataDirLabel
Var headwaveConfigDataDirText
Var headwaveConfigWkDirLabel
Var headwaveConfigWkDirText

!define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesCheck
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
!insertmacro MUI_PAGE_COMPONENTS

## This is the title on the Headwave Data Directory page
;!define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_HW)"
;!define MUI_PAGE_HEADER_TEXT "Headwave configuration"
; !define MUI_PAGE_HEADER_SUBTEXT "Select the folder which Headwave can use as a data storage."
Page custom HeadwaveConfiguration

; ; HW Data 
; !define MUI_PAGE_CUSTOMFUNCTION_PRE hw_data_pre
; !define MUI_PAGE_CUSTOMFUNCTION_SHOW hw_data_dir
; !define MUI_DIRECTORYPAGE_VARIABLE $HW_DATA_DIR
; !insertmacro MUI_PAGE_DIRECTORY

; ## This is the title on the Headwave Workspace Directory page
; !define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_HW_WK)"
; !define MUI_PAGE_HEADER_TEXT "Choose Headwave Workspace directory"
; !define MUI_PAGE_HEADER_SUBTEXT "Select the folder which Headwave can use as a workspace."

; # HW Workspaces
; !define MUI_PAGE_CUSTOMFUNCTION_PRE hw_wk_pre
; !define MUI_PAGE_CUSTOMFUNCTION_SHOW hw_wk_dir 
; !define MUI_DIRECTORYPAGE_VARIABLE $HW_WORKSPACE_DIR
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES    
 
## This is the title on the Headwave installation Directory page to obtain directory for %HEADWAVE_ROOT_DIR
!define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_HW_INST)"
!define MUI_PAGE_HEADER_TEXT "Choose Headwave Plugin installation directory"
!define MUI_PAGE_HEADER_SUBTEXT "Select the folder where Headwave is presently installed to set environment variable."
 
!define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesHeadwaveProg
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

; ...

Function HeadwaveConfiguration
  !insertmacro MUI_HEADER_TEXT "Headwave configuration" "Select the respective folders for Headwave."
  nsDialogs::Create 1018
  Pop $headwaveConfigDialog

  ${NSD_CreateLabel} 0 0 100% 12u "Select the folder which Headwave can use as a data storage:"
  Pop $headwaveConfigDataDirLabel
       
  ${NSD_CreateText} 10% 20u 80% 12u "C:\HW-Data"
  Pop $headwaveConfigDataDirText
  StrCpy $HW_DATA_DIR $headwaveConfigDataDirText   
  
  ${NSD_CreateLabel} 0 40u 80% 12u "Select the folder which Headwave can use as a workspace:"
  Pop $headwaveConfigWkDirLabel

  ${NSD_CreateText} 10% 60u 80% 12u "C:\HW-Workspaces"
  Pop $headwaveConfigWkDirText
  StrCpy $HW_WORKSPACE_DIR $headwaveConfigWkDirText        

  ;${NSD_CreateLabel} 0 80u 80% 12u "Select the folder where Headwave is installed:"
  ;Pop $headwaveConfigProgramDirLabel

  ;StrCpy $headwaveConfigProgramDirText $HeadwaveInstallDir
  ;${NSD_CreateText} 10% 100u 80% 12u $HeadwaveInstallDir
  ;Pop $headwaveConfigProgramDirText
  ;StrCpy $HeadwaveInstallDir $headwaveConfigProgramDirText           

  ;MessageBox MB_OK 'HeadwaveConfiguration: HeadwaveInstallDir = $HeadwaveInstallDir; headwaveConfigProgramDirText = $headwaveConfigProgramDirText'

  SetCtlColors $headwaveConfigHwnd 0xFF0000 0xFFFFFF
  
  nsDialogs::Show        
FunctionEnd

但问题是它的 HeadwaveConfiguration nsDialog 页面获得调用以获取 HW_DATA_DIRHW_WORKSPACE_DIR,但是它只是跳转到开始安装 MyApp 而不是首先安装Headwave 组件,然后继续安装 MyApp

有人有什么建议吗? TIA。

更新:

这是我更新代码的方式,但它在跳转到 MyApp 安装页面之前仍然没有安装 Headwave 组件:

!define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesCheck
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
!insertmacro MUI_PAGE_COMPONENTS

## This is the title on the Headwave Data Directory page
!define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_HW)"
!define MUI_PAGE_HEADER_TEXT "Headwave configuration"
!define MUI_PAGE_CUSTOMFUNCTION_PRE HeadwaveConfigurationPre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW HeadwaveConfigurationShow
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES    
 
## This is the title on the Headwave installation Directory page to obtain directory for %HEADWAVE_ROOT_DIR%
!define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_HW_INST)"
!define MUI_PAGE_HEADER_TEXT "Choose Headwave Plugin installation directory"
!define MUI_PAGE_HEADER_SUBTEXT "Select the folder where Headwave is presently installed to set environment variable."

Function HeadwaveConfigurationPre
  !insertmacro MUI_HEADER_TEXT "Headwave configuration" "Select the respective folders for Headwave."
  nsDialogs::Create 1018
  Pop $headwaveConfigDialog

  ${NSD_CreateLabel} 0 0 100% 12u "Select the folder which Headwave can use as a data storage:"
  Pop $headwaveConfigDataDirLabel
       
  ${NSD_CreateText} 10% 20u 80% 12u "C:\HW-Data"
  Pop $headwaveConfigDataDirText
  StrCpy $HwDataDir $headwaveConfigDataDirText   
  
  ${NSD_CreateLabel} 0 40u 80% 12u "Select the folder which Headwave can use as a workspace:"
  Pop $headwaveConfigWkDirLabel

  ${NSD_CreateText} 10% 60u 80% 12u "C:\HW-Workspaces"
  Pop $headwaveConfigWkDirText
  StrCpy $HwWorkspaceDir $headwaveConfigWkDirText        

  ;${NSD_CreateLabel} 0 80u 80% 12u "Select the folder where Headwave is installed:"
  ;Pop $headwaveConfigProgramDirLabel

  ;StrCpy $headwaveConfigProgramDirText $HeadwaveInstallDir
  ;${NSD_CreateText} 10% 100u 80% 12u $HeadwaveInstallDir
  ;Pop $headwaveConfigProgramDirText
  ;StrCpy $HeadwaveInstallDir $headwaveConfigProgramDirText           

  SetCtlColors $headwaveConfigHwnd 0xFF0000 0xFFFFFF
  
  nsDialogs::Show        
FunctionEnd
 
Function HeadwaveConfigurationShow
    MessageBox MB_OK 'HeadwaveConfiguration: HeadwaveInstallDir = $HeadwaveInstallDir; headwaveConfigProgramDirText = $headwaveConfigProgramDirText'        
FunctionEnd

## Section 1
Section "MyPartnerApp Plugin" SEC1
  MessageBox MB_OK 'Headwave Plugin #1: INSTDIR = $INSTDIR'
  ${If} ${SectionIsSelected} ${SEC1}    
    ${StrContains} $0 "MyPartnerApp" "$INSTDIR" 
    StrCmp $0 "" notfoundMyPartnerApp
    Goto doneMyPartnerApp
    doneMyPartnerApp:
      MessageBox MB_OK 'Headwave Plugin #2: HW_DATA_DIR = $HW_DATA_DIR'
      SetOutPath "$HW_DATA_DIR"
      ${StrContains} $0 "Data" "$HW_DATA_DIR"
      StrCmp $0 "" notfoundHwData
      Goto doneHwData
      ;MessageBox MB_OK 'Did not find MyApp string'
    doneHwData: 
    
      ##All the files in Group 0 will be installed to the same location,$HW_DATA_DIR
      MessageBox MB_OK 'Headwave Plugin #3: HW_DATA_DIR = $HW_DATA_DIR'
      SetOutPath "$HW_DATA_DIR"
      CreateDirectory "$HW_DATA_DIR"
      CreateDirectory "$HW_DATA_DIR\MyApp-Plugins"
      CreateDirectory "$HW_DATA_DIR\MyApp-Plugins\ComputePlugin"
      CreateDirectory "$HW_DATA_DIR\MyApp-Plugins\ExtensionPlugin"                                       

      File /oname=$HW_DATA_DIR\MyApp-Plugins\ComputePlugin\computeplugin.xplot.dll computeplugin.xplot.dll
      File /oname=$HW_DATA_DIR\MyApp-Plugins\ComputePlugin\computeplugin.VirtualVolume.dll computeplugin.VirtualVolume.dll
             
      File /oname=$HW_DATA_DIR\MyApp-Plugins\ExtensionPlugin\hwProxyInterface.MyApp.dll hwProxyInterface.MyApp.dll

      # MyPartnerApp workspace
      CreateDirectory "$HW_WORKSPACE_DIR"      
      
      ##All the files in Group 1 will be installed to the same location,$INSTDIR
      SetOutPath "$INSTDIR"
      ;messagebox mb_ok "MyPartnerApp Program: INSTDIR is $INSTDIR"
      
      # set environment variable for current user
      WriteRegExpandStr ${env_hkcu} HEADWAVE_ROOT_DIR $INSTDIR
      # save the selected headwave program directory
      StrCpy $MyPartnerAppSelectedInstallDir $INSTDIR
      # make sure windows knows about the change
      SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000

      # Install Sound-MyApp python scripts
      CreateDirectory $INSTDIR\python\hwtoolkits\MyCompany
      File __init__.py
      File MyAppConfig.py
      File MyAppPlugin.py
      
      CopyFiles $INSTDIR\*.py $INSTDIR\python\hwtoolkits\MyCompany

    notfoundHwData:          
    notfoundMyPartnerApp:
      ; Do nothing
  ${Else}
    Abort
  ${EndIf}          
SectionEnd

我原以为应该先调用 HeadwaveConfigurationPre,这样 $HW_DATA_DIR 应该是 C:\HW-Data,但我添加的其中一个消息框显示了这一点:

Headwave Plugin #2: HW_DATA_DIR = 6494062

更新 2:

感谢您的反馈,@Anders。

这是我的最新代码,最初它获取 $HwDataDir$HwWorkspaceDir 的值:

https://pastebin.com/VsT0MJf1 注意:我之前只在 https://pastebin.com/DJTLQ05D

中粘贴了部分代码

这是一个对话框,显示最初正在获取的值:

enter image description here

接下来进入插件安装页面:

enter image description here

但最终还是到了这行代码:

MessageBox MB_OK 'Headwave Plugin #2: HwDataDir = $HwDataDir'

在这种情况下,$HwDataDir 又是一个数字:

enter image description here

你能告诉我,这怎么会发生?为什么值会从 C:\HW-Data 变为 1181026? TIA。

解决方法

您不能将 MUI_PAGE_CUSTOMFUNCTION_* 与 nsDialogs 一起使用。在上次更新中 $HwDataDir 包含一个数字,因为它是文本控件的句柄,而不是它的文本。即使您要求其文本,那也是错误的时间,您也应该在休假回调中这样做。自定义页面只有 create 和 leave 回调,没有 pre 和 show!

以下是来自 nsDialogs 文档的示例代码的一部分:

Page custom nsDialogsPage nsDialogsPageLeave
Page instfiles

Function nsDialogsPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateLabel} 0 0 100% 12u "Hello,welcome to nsDialogs!"
    Pop $Label

    ${NSD_CreateText} 0 13u 100% -13u "Type something here..."
    Pop $Text

    nsDialogs::Show

FunctionEnd

Function nsDialogsPageLeave

    ${NSD_GetText} $Text $0
    MessageBox MB_OK "You typed:$\n$\n$0"

FunctionEnd

您的代码包含其他问题,例如

Section "MyPartnerApp Plugin" SEC1
  ${If} ${SectionIsSelected} ${SEC1}    

这毫无意义,你不能那样检查自己。 IsPROG0HwDataSelected 函数非常糟糕,您应该使用 ${If} 和适当的节索引从头开始重写它。

更新 2:

在您的新代码中,StrCpy $HwDataDir $headwaveConfigDataDirText 是句柄“损坏”的地方。你不需要 StrCpy,你在 leave 函数中只需要 ${NSD_GetText} $headwaveConfigDataDirText $HwDataDir

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)> insert overwrite table dwd_trade_cart_add_inc > select data.id, > data.user_id, > data.course_id, > date_format(
错误1 hive (edu)> insert into huanhuan values(1,'haoge'); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive> show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 <configuration> <property> <name>yarn.nodemanager.res