NSIS选择选项异常行为

NSIS选择选项异常行为,nsis,Nsis,我不是NSIS专家,但我过得去!我正在为我们正在构建的新软件安装一个新的安装程序,我已经为安装程序配置了两个可能的路径,安装或升级 其思想是,当用户选择任何升级选项时,所有可能选择安装的选项都将被取消选择,反之亦然 例如,当一个用户在安装路径下选择一个选项时,该路径的所有选项都会被选中,并且不能取消选中,除非您在升级路径下选择一个选项,有趣的是,在这之后,选项的选择似乎会按需进行 这是我的代码,我在这里遗漏了什么 ;-------------------------------- ;Includ

我不是NSIS专家,但我过得去!我正在为我们正在构建的新软件安装一个新的安装程序,我已经为安装程序配置了两个可能的路径,安装或升级

其思想是,当用户选择任何升级选项时,所有可能选择安装的选项都将被取消选择,反之亦然

例如,当一个用户在安装路径下选择一个选项时,该路径的所有选项都会被选中,并且不能取消选中,除非您在升级路径下选择一个选项,有趣的是,在这之后,选项的选择似乎会按需进行

这是我的代码,我在这里遗漏了什么

;--------------------------------
;Includes
;--------------------------------

  !include "MUI2.nsh"
  !include "nsDialogs.nsh"
  !include "LogicLib.nsh"
  !include "Sections.nsh"
  !include "oledb.nsh"
  !include "WinMessages.nsh"
  !include "ReplaceInFile.nsh"



;--------------------------------
;General
;--------------------------------

    ;Name and file
    Name "App"
    OutFile "AppName ${Version}.exe"

    ;Default installation folder
    InstallDir "C:\appFolder"

    ;Request application privileges for Windows Vista +
    RequestExecutionLevel admin

;--------------------------------
;Interface Settings
;--------------------------------

    !define MUI_ABORTWARNING
    Var Dialog
    Var SQLServer
    Var SQLUsername
    Var SQLPassword
    Var SDatabase
    Var CoreDatabase
    Var UIDatabase

    ShowInstDetails "show"

;--------------------------------
;Pages
;--------------------------------

    !insertmacro MUI_PAGE_WELCOME
    !insertmacro MUI_PAGE_LICENSE "LIC.rtf"
    !insertmacro MUI_PAGE_COMPONENTS
    Page Custom SQLConnectionDetails SQLConnectionDetailsPageLeave
    Page Custom DatabaseDetails DatabaseDetailsLeave
    !insertmacro MUI_PAGE_DIRECTORY
    !insertmacro MUI_PAGE_INSTFILES
    !insertmacro MUI_PAGE_FINISH

;--------------------------------
;onInit
;--------------------------------

Function .onInit
    InitPluginsDir
    StrCpy $1 "SecMain"

FunctionEnd

;--------------------------------
;Page functions
;--------------------------------   

Function SQLConnectionDetails
    !insertmacro MUI_HEADER_TEXT $(SQLServerDetailsTitle) $(SQLServerDetailsSubTitle)
    nsDialogs::Create 1018
    pop $Dialog
    ${If} $Dialog == error
        Abort
    ${EndIf}

    ;x, y, width, height and text
    ${NSD_CreateLabel} 0 0 100% 10u "Enter the name of the SQL server that AppName is to be installed on"
    pop $1
    ${NSD_CreateText} 0 10u 150u 12u ""
    pop $SQLServer

    ${NSD_CreateLabel} 0 25u 100% 10u "Enter the database name"
    pop $2
    ${NSD_CreateText} 0 35u 100u 12u ""
    pop $SDatabase

    ${NSD_CreateLabel} 0 50u 100% 10u "Enter SQL username"
    pop $3
    ${NSD_CreateText}} 0 60u 100u 12u ""
    pop $SQLUsername

    ${NSD_CreateLabel} 0 75u 100% 10u "Enter SQL password"
    pop $4
    ${NSD_CreatePassword} 0  85u 100u 12u ""
    pop $SQLPassword

    nsDialogs::Show
FunctionEnd

Function SQLConnectionDetailsPageLeave
    ${NSD_GetText} $SQLServer $SQLServer
    ${NSD_GetText} $SQLUsername $SQLUsername
    ${NSD_GetText} $SQLPassword $SQLPassword
    ${NSD_GetText} $SDatabase $SDatabase
    messagebox MB_OK "We will now attempt to connect to the database server."
    MSSQL_OLEDB::SQL_Logon "$SQLServer" "$SQLUsername" "$SQLPassword"
    pop $0

    ${If} $0 = 0
        ;messagebox MB_OK "Connection sucessful"
    ${Else}
        messagebox MB_OK "I encountered an issue whilst trying to connect to the database. Please check your details and try again."
        abort
    ${EndIf}

    MSSQL_OLEDB::SQL_Logout
FunctionEnd

Function DatabaseDetails
    !insertmacro MUI_HEADER_TEXT $(DatabaseNamesTitle) $(DatabaseNamesSubTitle)
    nsDialogs::Create 1018
    pop $Dialog
    ${If} $Dialog == error
        Abort
    ${EndIf}

    ;x, y, width, height and text
    ${NSD_CreateLabel} 0 0 100% 10u "Enter the name to be given to the Core database"
    pop $1
    ${NSD_CreateText} 0 10u 150u 12u ""
    pop $CoreDatabase

    ${NSD_CreateLabel} 0 25u 100% 10u "Enter the name to be given to the UI database"
    pop $2
    ${NSD_CreateText} 0 35u 100u 12u ""
    pop $UIDatabase

    nsDialogs::Show
 FunctionEnd

 Function DatabaseDetailsLeave
 ${NSD_GetText} $CoreDatabase $CoreDatabase
 ${NSD_GetText} $UIDatabase $UIDatabase
 FunctionEnd

;--------------------------------
;Languages
;--------------------------------

  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections
;--------------------------------
InstType "New Install"
InstType "New Install - Full"
InstType "Upgrade"

;------------
;New Install
;------------

SectionGroup /e "!Install" SecGroupNewInstall
    Section "Main App" SecMain

    SectionEnd

    Section /o "App1" SecApp1

    SectionEnd

    Section /o "App2" SecApp2

    SectionEnd

    Section /o "App3" SecApp3

    SectionEnd

    Section /o "App4" SecApp4

    SectionEnd

    SectionGroup /e "Optional" SubSecGroupNewInstall
        Section /o "App5" SecApp5

        SectionEnd

        Section /o "App6" SecApp6

        SectionEnd  

        Section /o "App7" SecApp7

        SectionEnd
    SectionGroupEnd 
SectionGroupEnd

SectionGroup /e "!Upgrade" SecGroupUpgrade
    Section /o "Upgrade Main App" SecMainUpgrade        
    SectionEnd
SectionGroupEnd

;--------------------------------
;onSelChange
;--------------------------------

Function .onSelChange

    !insertmacro StartRadioButtons $1
        !insertmacro RadioButton ${SecMain}
        !insertmacro RadioButton ${SecMainUpgrade}
    !insertmacro EndRadioButtons

    !insertmacro SectionFlagIsSet ${SecMain} ${SF_SELECTED} InstisSel InstnotSel
        InstnotSel:
            !insertmacro UnselectSection ${SecGroupNewInstall}
        InstisSel:

    !insertmacro SectionFlagIsSet ${SecMainUpgrade} ${SF_SELECTED} UpgisSel UpgnotSel
        UpgnotSel:
    !insertmacro UnselectSection ${SecGroupUpgrade}
        UpgisSel:

FunctionEnd

我已经回答了我自己的问题!! 这个问题既与时间有关,也与我的onInit功能有关。我已将我的onInit函数移到我的节组下面,并更正了StrCpy,现在包含了正确的节参考,请参阅下面的更正代码:

;--------------------------------
;Includes
;--------------------------------

  !include "MUI2.nsh"
  !include "nsDialogs.nsh"
  !include "LogicLib.nsh"
  !include "Sections.nsh"
  !include "oledb.nsh"
  !include "WinMessages.nsh"
  !include "ReplaceInFile.nsh"



;--------------------------------
;General
;--------------------------------

    ;Name and file
    Name "App"
    OutFile "AppName ${Version}.exe"

    ;Default installation folder
    InstallDir "C:\appFolder"

    ;Request application privileges for Windows Vista +
    RequestExecutionLevel admin

;--------------------------------
;Interface Settings
;--------------------------------

    !define MUI_ABORTWARNING
    Var Dialog
    Var SQLServer
    Var SQLUsername
    Var SQLPassword
    Var SDatabase
    Var CoreDatabase
    Var UIDatabase

    ShowInstDetails "show"

;--------------------------------
;Pages
;--------------------------------

    !insertmacro MUI_PAGE_WELCOME
    !insertmacro MUI_PAGE_LICENSE "LIC.rtf"
    !insertmacro MUI_PAGE_COMPONENTS
    Page Custom SQLConnectionDetails SQLConnectionDetailsPageLeave
    Page Custom DatabaseDetails DatabaseDetailsLeave
    !insertmacro MUI_PAGE_DIRECTORY
    !insertmacro MUI_PAGE_INSTFILES
    !insertmacro MUI_PAGE_FINISH

;--------------------------------
;Page functions
;--------------------------------   

Function SQLConnectionDetails
    !insertmacro MUI_HEADER_TEXT $(SQLServerDetailsTitle) $(SQLServerDetailsSubTitle)
    nsDialogs::Create 1018
    pop $Dialog
    ${If} $Dialog == error
        Abort
    ${EndIf}

    ;x, y, width, height and text
    ${NSD_CreateLabel} 0 0 100% 10u "Enter the name of the SQL server that AppName is to be installed on"
    pop $1
    ${NSD_CreateText} 0 10u 150u 12u ""
    pop $SQLServer

    ${NSD_CreateLabel} 0 25u 100% 10u "Enter the database name"
    pop $2
    ${NSD_CreateText} 0 35u 100u 12u ""
    pop $SDatabase

    ${NSD_CreateLabel} 0 50u 100% 10u "Enter SQL username"
    pop $3
    ${NSD_CreateText}} 0 60u 100u 12u ""
    pop $SQLUsername

    ${NSD_CreateLabel} 0 75u 100% 10u "Enter SQL password"
    pop $4
    ${NSD_CreatePassword} 0  85u 100u 12u ""
    pop $SQLPassword

    nsDialogs::Show
FunctionEnd

Function SQLConnectionDetailsPageLeave
    ${NSD_GetText} $SQLServer $SQLServer
    ${NSD_GetText} $SQLUsername $SQLUsername
    ${NSD_GetText} $SQLPassword $SQLPassword
    ${NSD_GetText} $SDatabase $SDatabase
    messagebox MB_OK "We will now attempt to connect to the database server."
    MSSQL_OLEDB::SQL_Logon "$SQLServer" "$SQLUsername" "$SQLPassword"
    pop $0

    ${If} $0 = 0
        ;messagebox MB_OK "Connection sucessful"
    ${Else}
        messagebox MB_OK "I encountered an issue whilst trying to connect to the database. Please check your details and try again."
        abort
    ${EndIf}

    MSSQL_OLEDB::SQL_Logout
FunctionEnd

Function DatabaseDetails
    !insertmacro MUI_HEADER_TEXT $(DatabaseNamesTitle) $(DatabaseNamesSubTitle)
    nsDialogs::Create 1018
    pop $Dialog
    ${If} $Dialog == error
        Abort
    ${EndIf}

    ;x, y, width, height and text
    ${NSD_CreateLabel} 0 0 100% 10u "Enter the name to be given to the Core database"
    pop $1
    ${NSD_CreateText} 0 10u 150u 12u ""
    pop $CoreDatabase

    ${NSD_CreateLabel} 0 25u 100% 10u "Enter the name to be given to the UI database"
    pop $2
    ${NSD_CreateText} 0 35u 100u 12u ""
    pop $UIDatabase

    nsDialogs::Show
 FunctionEnd

 Function DatabaseDetailsLeave
 ${NSD_GetText} $CoreDatabase $CoreDatabase
 ${NSD_GetText} $UIDatabase $UIDatabase
 FunctionEnd

;--------------------------------
;Languages
;--------------------------------

  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections
;--------------------------------
InstType "New Install"
InstType "New Install - Full"
InstType "Upgrade"

;------------
;New Install
;------------

SectionGroup /e "!Install" SecGroupNewInstall
    Section "Main App" SecMain

    SectionEnd

    Section /o "App1" SecApp1

    SectionEnd

    Section /o "App2" SecApp2

    SectionEnd

    Section /o "App3" SecApp3

    SectionEnd

    Section /o "App4" SecApp4

    SectionEnd

    SectionGroup /e "Optional" SubSecGroupNewInstall
        Section /o "App5" SecApp5

        SectionEnd

        Section /o "App6" SecApp6

        SectionEnd  

        Section /o "App7" SecApp7

        SectionEnd
    SectionGroupEnd 
SectionGroupEnd

SectionGroup /e "!Upgrade" SecGroupUpgrade
    Section /o "Upgrade Main App" SecMainUpgrade        
    SectionEnd
SectionGroupEnd

;--------------------------------
;onInit
;--------------------------------

Function .onInit
    InitPluginsDir
    StrCpy $1 ${SecMain}

FunctionEnd

;--------------------------------
;onSelChange
;--------------------------------

Function .onSelChange

    !insertmacro StartRadioButtons $1
        !insertmacro RadioButton ${SecMain}
        !insertmacro RadioButton ${SecMainUpgrade}
    !insertmacro EndRadioButtons

    !insertmacro SectionFlagIsSet ${SecMain} ${SF_SELECTED} InstisSel InstnotSel
        InstnotSel:
            !insertmacro UnselectSection ${SecGroupNewInstall}
        InstisSel:

    !insertmacro SectionFlagIsSet ${SecMainUpgrade} ${SF_SELECTED} UpgisSel UpgnotSel
        UpgnotSel:
    !insertmacro UnselectSection ${SecGroupUpgrade}
        UpgisSel:

FunctionEnd