如何从 Internet 下载文件并将其路径应用到 MUI_PAGE_LICENSE 宏?

How can i download a file from the internet and apply its path to MUI_PAGE_LICENSE macro?

这里是新手

我目前正在尝试弄清楚如何将下载文件的路径分配给 MUI_PAGE_LICENSE 宏,如下所示:

!insertmacro MUI_PAGE_LICENSE blah_txt_location

我知道我可以 inetc::get /SILENT "online file location" "install location" /end 来下载文件 - 但我的问题是 !insertmacro 在编译期间是 运行 并且下载文件是在 运行 时间(我认为我是正确的 - 如果不正确请告诉我)

那我该怎么做呢?

编辑:事实证明 anders 代码确实有效,但是添加 OutFile "App.exe" 会使它崩溃

不能直接赋值,要动态加载:

!include MUI2.nsh

!define MUI_PAGE_CUSTOMFUNCTION_SHOW DelayLoadLicenseFile
!tempfile dummylicense
!appendfile "${dummylicense}" "$\n"
!insertmacro MUI_PAGE_LICENSE "${dummylicense}"
!delfile "${dummylicense}"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English

Function DelayLoadLicenseFile
SendMessage $mui.Licensepage.LicenseText ${EM_LIMITTEXT} -1 ""
FileOpen  "$PluginsDir\license.txt" R
${If}  P<> 0
    FileSeek  0 END 
    FileSeek  0 SET
    System::Call '*(&m)p.r3'
    System::Call 'KERNEL32::ReadFile(p,p,i,*i,p0)'
    System::Call 'USER32::SendMessageA(p$mui.Licensepage.LicenseText,i${WM_SETTEXT},p0,p)'
    System::Free 
    FileClose 
#${Else}
#   MessageBox mb_iconStop "blah blah license!"
#   Quit
${EndIf}
FunctionEnd

Function .onInit
InitPluginsDir
inetc::get /SILENT "http://example.com/license.txt" "$PluginsDir\license.txt" /end
Pop [=10=]
Messagebox mb_ok Debug:[=10=]
FunctionEnd

虽然您可能不希望将默认许可证留空,但如果用户不在线或服务器已关闭,下载可能会失败。如果您想加载 RTF 文件,您可能需要 stream it in...