使用FileFunc.nsh头文件判断文件版本

示例一:

需要系统中已安装WINRAR 32位版本,否则请自行修改测试代码。

Name "测试"
Caption "$(^Name)"
OutFile "测试.exe"
SilentInstall silent
XPStyle on
!include "FileFunc.nsh"

Section .onInit
ReadRegStr $1 HKLM "SoftwareWinRAR" "exe32"
MessageBox MB_OK "$1"
${GetFileVersion} $1 $R0
MessageBox MB_OK "$R0"
SectionEnd

示例二:

拿WMP10做一个例子。关于WMP10的原始安装文件,可以下载后通过/C /T:D:Windows Media Player参数(参数说明:将文件解开到D:Windows Media Player文件夹)得到。

首先,引入头文件:

;首先,引入头文件:
!include "FileFunc.nsh"
;然后,写详细的代码:
Section "WMP" SEC_WMP
${GetFileVersion} "$PROGRAMFILESWindows Media Playerwmplayer.exe" $R1
Pop $R1
  ${If} $R1 < '10.0.0.3802'
  MessageBox MB_YESNO "您的Windows Media Player版本过低,是否升级到推荐版本?" IDNO NoReadme

  SetDetailsPrint textonly
  DetailPrint "正在安装 Windows Media Player10..."
  SetDetailsPrint listonly

  SetOutPath "$TEMPMP10"
  File "Windows Media Player10*.*"
  ExecWait '$TEMPMP10setup_wm.exe /Q' $R1
  RMDir /r "$TEMPMP10"
  ${EndIf}
  NoReadme:
SectionEnd
© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容