【发布时间】:2018-07-11 19:08:05
【问题描述】:
下面是我编写的一个程序,它利用了 wiki 中给定的 IpConfig 函数。我试图让用户输入文本文件的名称($Text),然后用计算机的 ipconfig 信息填充该文本文件。这可以在命令提示符下轻松完成,但我的目标是希望让它在 NSIS 上运行。我能够使用 DumpLog 转储从 detailprints 获取的所有数据。这个函数产生我需要的 .txt 文件。我正在努力让用户设置这个 .txt 文件的名称。
我遇到的问题是程序在第一个自定义页面之后结束。我可以输入文件的名称,但必须点击关闭并且程序中止。我已尝试创建 CustomLeave 页面,但无法将 ipconfig 功能与其集成。
不幸的是,即使在进一步重组之后,我也可以创建没有名称的文本文件,该名称完全填充了所需的数据,这告诉我正在传递一个空的“文本”名称变量。
感谢您的帮助!谢谢。
!addplugindir "${NSISDIR}\Plugins\x86-unicode"
!addplugindir "${NSISDIR}\Plugins\x86-ansi"
!addplugindir "${NSISDIR}\Plugins"
!include "LogicLib.nsh"
!include "MUI2.nsh"
!include "winMessages.nsh"
!include "nsDialogs.nsh"
!Macro ShowResult ItemString
Pop $0
Pop $1
${if} $0 == "ok"
DetailPrint "${ItemString} $1"
${Else}
DetailPrint "${ItemString} Error: $1"
${EndIf}
!MacroEnd
!Macro ShowMultiResult ItemString
Pop $0
Pop $1
${if} $0 != "ok"
DetailPrint "${ItemString} Error: $1"
${EndIf}
!MacroEnd
;!define LVM_GETITEMCOUNT 0x1004
;!define LVM_GETITEMTEXT 0x102D
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "Some location.bmp"
!define MUI_HEADERIMAGE_RIGHT
!insertmacro MUI_LANGUAGE "English"
OutFile "something.exe"
Page custom custompage
Var dialog
Var Label
Var Text
Var TextBox
Function custompage
!insertmacro MUI_HEADER_TEXT "Something" "Tool"
nsDialogs::Create 1018
Pop $dialog
${NSD_CreateLabel} 0 0 100% 12u "enter text name"
Pop $Label
${NSD_CreateText} 0 12u 93% 12u $Text
Pop $TextBox
nsDialogs::Show
FunctionEnd
Section
DetailPrint "Windows IP-configuration"
DetailPrint ""
IpConfig::GetHostName
!InsertMacro ShowResult " Host Name.......................:"
IpConfig::GetPrimaryDNSSuffix
!InsertMacro ShowResult " Primary DNS Suffix..............:"
IpConfig::GetNodeType
!InsertMacro ShowResult " Node Type.......................:"
IpConfig::IsIPRoutingEnabled
!InsertMacro ShowResult " IP Routing Enabled..............:"
IpConfig::IsWINSProxyEnabled
!InsertMacro ShowResult " WINS Proxy Enabled..............:"
IpConfig::GetDNSSuffixSearchList
!InsertMacro ShowResult " DNS Suffix Search List..........:"
DetailPrint ""
GetFunctionAddress $2 EnabledAdaptersCallback
IpConfig::GetEnabledNetworkAdaptersIDsCB $2
!InsertMacro ShowMultiResult " GetEnabledNetworkAdaptersIDs:"
StrCpy $0 "$Desktop\$Text.txt"
Push $0
Call DumpLog
SectionEnd
复制以下 DumpLog 和 IPConfig 函数 - 为清楚起见已删除。 ================================================== =======================
【问题讨论】:
标签: nsis