我想在部分描述中显示安装程序中安装的可执行文件的版本吗?
LangString DESC_SecSoftware ${LANG_ENGLISH} "Software PX"
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${DescText} "Software test"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
如何读取test.exe的文件版本?
可以像这样读取文件版本:
${GetFileVersion} "C:\ftp\programm.exe" $ProgramVersion
!include "FileFunc.nsh"
但路径必须是绝对的。我无法读取安装中包含的fileVersion whitch。
答案 0 :(得分:7)
${GetFileVersion}
宏将允许您在执行安装的计算机上读取文件版本在运行时,并且文件当前不在安装程序之外.exe
相反,您可以使用在编译时执行的GetDllVersionLocal
,并从程序员主机上的原始.exe中获取该版本。
!include "logiclib.nsh"
ShowInstDetails show
OutFile "exeversion.exe"
!define exe_to_read "some.exe"
Section
DetailPrint "getting version $EXEPATH"
GetDllVersionLocal "${exe_to_read}" $R0 $R1 ;the two values were read during compilation
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"
DetailPrint "version read: $0"
SectionEnd