我正在尝试使用具有自定义形式的设置来创建安装:
configform.nsdInc:
; =========================================================
; This file was generated by NSISDialogDesigner 1.4.2.0
; http://coolsoft.altervista.org/nsisdialogdesigner
;
; Do not edit it manually, use NSISDialogDesigner instead!
; =========================================================
; handle variables
Var hCtl_configForm
Var hCtl_configForm_imgQuality
Var hCtl_configForm_wpctrlPort
Var hCtl_configForm_wpctrlIp
Var hCtl_configForm_atmCmdPort
Var hCtl_configForm_atmCmdIp
Var hCtl_configForm_Label3
Var hCtl_configForm_Label2
Var hCtl_configForm_Label1
Var T0
Var T1
Var T2
Var T3
Var T4
!include nsDialogs.nsh
; dialog create function
Function fnc_configForm_Create
; === configForm (type: Dialog) ===
nsDialogs::Create 1018
Pop $hCtl_configForm
${If} $hCtl_configForm == error
Abort
${EndIf}
!insertmacro MUI_HEADER_TEXT "Dialog title..." "Dialog subtitle..."
; === imgQuality (type: ComboBox) ===
${NSD_CreateComboBox} 77.67u 43.69u 63.85u 12.92u ""
Pop $hCtl_configForm_imgQuality
${NSD_CB_AddString} $hCtl_configForm_imgQuality "15"
....
${NSD_CB_AddString} $hCtl_configForm_imgQuality "97"
; === wpctrlPort (type: Text) ===
${NSD_CreateText} 235.65u 24u 57.92u 12.31u ""
Pop $hCtl_configForm_wpctrlPort
; === wpctrlIp (type: Text) ===
${NSD_CreateText} 77.67u 24u 154.03u 12.31u ""
Pop $hCtl_configForm_wpctrlIp
; === atmCmdPort (type: Text) ===
${NSD_CreateText} 235.65u 3.69u 57.92u 12.31u ""
Pop $hCtl_configForm_atmCmdPort
; === atmCmdIp (type: Text) ===
${NSD_CreateText} 77.67u 3.69u 154.03u 12.31u ""
Pop $hCtl_configForm_atmCmdIp
; === Label3 (type: Label) ===
${NSD_CreateLabel} 7.9u 44.92u 65.82u 11.69u "Image quality:"
Pop $hCtl_configForm_Label3
; === Label2 (type: Label) ===
${NSD_CreateLabel} 7.9u 25.85u 65.82u 11.69u "WPCTRL IP\Port:"
Pop $hCtl_configForm_Label2
; === Label1 (type: Label) ===
${NSD_CreateLabel} 7.9u 5.54u 65.82u 11.69u "ATMCMD IP\Port:"
Pop $hCtl_configForm_Label1
FunctionEnd
; dialog show function
Function fnc_configForm_Show
Call fnc_configForm_Create
nsDialogs::Show
FunctionEnd
Function fnc_save_config
${NSD_GetText} hCtl_configForm_atmCmdIp $T0
${NSD_GetText} hCtl_configForm_atmCmdPort $T1
${NSD_GetText} hCtl_configForm_wpctrlIp $T2
${NSD_GetText} hCtl_configForm_wpctrlPort $T3
${NSD_GetText} hCtl_configForm_imgQuality $T4
FileOpen $5 "$INSTDIR\M3Remote.xml" w
FileWrite $5 "<Settings><Login>Remote</Login> <Communications><WP><Ip>"
FileWrite $5 $T2
FileWrite $5 "</Ip><Port>"
FileWrite $5 $T3
FileWrite $5 "</Port>"
...... FileWrite $ 5“ ru-RU” File关闭$ 5 FunctionEnd
.nsi主要脚本:
; Script generated by the HM NIS Edit Script Wizard.
SetCompressor /SOLID LZMA
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "MMMFFF"
!define PRODUCT_VERSION 1.0
!define PRODUCT_PUBLISHER "AAAA"
!define PRODUCT_WEB_SITE "http://e.com"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\M3Remote"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_DISTRIBUTION_FILE "MMMFFF_setup_${PRODUCT_VERSION}.exe"
RequestExecutionLevel admin
!define TARGETDIR "install"
!addplugindir "${TARGETDIR}"
; MUI 1.67 compatible
!include "MUI.nsh"
!include nsDialogs.nsh
; MUI Settings
!define MUI_ABORTWARNING
; Welcome page
!insertmacro MUI_PAGE_WELCOME
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "C:\Program Files\Lanit\M3Remote"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!include "configForm.nsdinc"
Page custom fnc_configForm_Show fnc_save_config
!insertmacro MUI_PAGE_FINISH
; Language files
!insertmacro MUI_LANGUAGE "Russian"
; MUI end
!include LogicLib.nsh
!include NsisXml.nsh
Name "M3Remote ${PRODUCT_VERSION}" ; название кнопки инсталлятора на панели задач
Caption "Установка M3Remote ${PRODUCT_VERSION}" ; заголовок окна инсталлятора
OutFile "M3Remote_setup_${PRODUCT_VERSION}.exe" ; имя файла инсталлятора
InstallDir "C:\Program Files\Lanit\M3Remote"
;------------------------------------------------------------------------------------------
Section Filecopy
CreateDirectory $INSTDIR
CreateDirectory $INSTDIR\Logs
WriteUninstaller "$INSTDIR\uninst.exe"
SetOutPath $INSTDIR
File /r binary\*
......... SectionEnd
Function un.onUninstSuccess
.....
FunctionEnd
Function un.onInit
....
FunctionEnd
Section uninstall
...............
SectionEnd
问题是,我完全无法弄清问题所在 $ {NSD_GetText} ,因为它离开会返回一个空字符串。 而且我被卡住了!
答案 0 :(得分:1)
您没有将有效的Window句柄传递给${NSD_GetText}
,因为您忘记了变量名上的$
前缀。将${NSD_GetText} hCtl_configForm_atmCmdIp $T0
更改为${NSD_GetText} $hCtl_configForm_atmCmdIp $T0
,等等。