跳转到内容

说明文档

生成安装包

以上未经测试

  • 自定义页面

  • 普通页面

    sh
    !include nsDialogs.nsh
    !include LogicLib.nsh
    !include MUI2.nsh
    
    Name nsDialogs
    OutFile nsDialogs.exe
    RequestExecutionLevel user
    ShowInstDetails show
    
    Var Dialog
    Var TextUser
    Var TextPass
    Var TextDbName
    Var TextPgDir
    
    Page custom pgPageCreate pgPageLeave
    !insertmacro MUI_PAGE_INSTFILES
    
    !insertmacro MUI_LANGUAGE "English"
    
    Function pgPageCreate
        !insertmacro MUI_HEADER_TEXT "Database Settings" "Provide PostgreSQL config and install directory."
    
        nsDialogs::Create 1018
        Pop $Dialog
    
        ${If} $Dialog == error
            Abort
        ${EndIf}
    
        ${NSD_CreateGroupBox} 10% 10u 80% 62u "PostgreSQL Database Settings"
        Pop $0
    
            ${NSD_CreateLabel} 20% 26u 20% 10u "Username:"
            Pop $0
    
            ${NSD_CreateText} 40% 24u 40% 12u "postgres"
            Pop $TextUser
    
            ${NSD_CreateLabel} 20% 40u 20% 10u "Password:"
            Pop $0
    
            ${NSD_CreatePassword} 40% 38u 40% 12u ""
            Pop $TextPass
    
            ${NSD_CreateLabel} 20% 54u 20% 10u "New Database:"
            Pop $0
    
            ${NSD_CreateText} 40% 52u 40% 12u "mydb"
            Pop $TextDbName
    
        ${NSD_CreateGroupBox} 5% 86u 90% 34u "PostgreSQL Install Path"
        Pop $0
    
            ${NSD_CreateDirRequest} 15% 100u 49% 12u "$PROGRAMFILES64\PostgreSQL\10"
            Pop $TextPgDir
    
            ${NSD_CreateBrowseButton} 65% 100u 20% 12u "Browse..."
            Pop $0
            ${NSD_OnClick} $0 OnDirBrowse
    
        nsDialogs::Show
    FunctionEnd
    
    Function OnDirBrowse
        ${NSD_GetText} $TextPgDir $0
        nsDialogs::SelectFolderDialog "Select Postgres Directory" "$0"
        Pop $0
        ${If} $0 != error
            ${NSD_SetText} $TextPgDir "$0"
        ${EndIf}
    FunctionEnd
    
    Function PgPageLeave
        ${NSD_GetText} $TextUser $0
        ${NSD_GetText} $TextPass $1
        ${NSD_GetText} $TextDbName $2
        ${NSD_GetText} $TextPgDir $3
        MessageBox MB_OK "User: $0, Pass: $1, Db: $2, PgDir: $3"
    FunctionEnd
    
    Section
        DetailPrint "Hello, World!"
    SectionEnd

    自定义界面

  • Net framework is installed on the computer and download/install one if it is not found https://github.com/alex-sitnikov/NsisDotNetChecker/blob/master/nsis/DotNetChecker.nsh

Released under the MIT License.