我必须将文件解压缩到我的NSIS安装程序中的输出文件夹。文件的名称包含其版本号。我需要一个方法来读取以我的文件名写的数字。
示例文件名:
MyFile_4.3_runtime_80968_x64.exe我使用以下代码自动读取它:
Var Version
Section
${GetFileVersion} "F:\FilesToBeInstalled\MyFile_4.3_runtime_?????_x64.exe" $Version
MessageBox MB_OK "Version: $Version"
SectionEnd以前它对我有用。但突然间,它就停止工作了。如果我写正确的数字而不是写?????,那么它就能工作。例如,以下代码适用于我:
Var Version
Section
${GetFileVersion} "F:\FilesToBeInstalled\MyFile_4.3_runtime_80698_x64.exe" $Version
MessageBox MB_OK "Version: $Version"
SectionEnd发布于 2017-01-17 12:27:44
GetFileVersion读取文件的版本-信息,它不解析文件名.这很可能是一个巧合,它以前起作用了。
您可以使用WordFind2x在两个分隔符之间搜索:
!include "WordFunc.nsh"
Var Version
Var File
Section
# find instances of MyFile_4.3_runtime*
FindFirst $0 $File "F:\FilesToBeInstalled\MyFile_4.3_runtime*.exe"
loop:
StrCmp $File "" done
# parse hit for version string
${WordFind2X} $File "MyFile_4.3_runtime_" ".exe" "-1" $Version
DetailPrint "$File contains version $Version"
FindNext $0 $File
Goto loop
done:
FindClose $0
SectionEndhttps://stackoverflow.com/questions/41693566
复制相似问题