最新消息:

FSP是NSIS根据文件大小动态控制进度条的插件

nsis 永恒心锁 2283浏览 0评论
/*
FSP是NSIS根据文件大小动态控制进度条的插件
Fsp增加了一些在安装释放文件时的动态控制,在NSIS中如果不设置压缩格式,
进度条就不会显示解压的进度一闪而过,Fsp插件增加了进度条控制.
Fsp插件首先用外部程序生成一个文件名和文件大小,然后再包含到文件中.
fn:文件名,即要释放的文件.
fs:文件大小,首先要指定fn.
int:更新进度条的时间间隔.
pbf:执行完成后,占用进度条停的位置以百分比计算.
此例子也使用了编译时命令,对于要扩展二重编译行为也值得参考.
*/
!AddPluginDir "../Plugins"
OutFile "FSP.exe"
#SetCompressor /SOLID lzma
!include "MUI2.nsh"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "SimpChinese"
!define FILENAME "gfs.exe" #要包含的文件
#编译时的命令,先调用gfs.exe生成文件名和文件大小
!delfile "gfs.nsi"
!appendfile "gfs.nsi" `OutFile "gfs.exe"$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `Function GetParameters$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" ` StrCpy $2 1$n`
!appendfile "gfs.nsi" ` StrLen $3 $CMDLINE$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `;Check for first char is quote, end will be quote or space $1$n`
!appendfile "gfs.nsi" ` StrCpy $0 $CMDLINE $2$n`
!appendfile "gfs.nsi" ` StrCmp $0 '"' 0 +3$n`
!appendfile "gfs.nsi" ` StrCpy $1 '"'$n`
!appendfile "gfs.nsi" ` Goto loop$n`
!appendfile "gfs.nsi" ` StrCpy $1 " "$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" ` loop:$n`
!appendfile "gfs.nsi" ` IntOp $2 $2 + 1$n`
!appendfile "gfs.nsi" ` StrCpy $0 $CMDLINE 1 $2$n`
!appendfile "gfs.nsi" ` StrCmp $0 $1 get$n`
!appendfile "gfs.nsi" ` StrCmp $2 $3 get$n`
!appendfile "gfs.nsi" ` Goto loop$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" ` get:$n`
!appendfile "gfs.nsi" ` IntOp $2 $2 + 1$n`
!appendfile "gfs.nsi" ` StrCpy $0 $CMDLINE 1 $2$n`
!appendfile "gfs.nsi" ` StrCmp $0 " " get$n`
!appendfile "gfs.nsi" ` StrCpy $0 $CMDLINE "" $2$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `; file name is in the $0$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `FunctionEnd$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `Function FileSize$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" ` SetOutPath "$EXEDIR"$n`
!appendfile "gfs.nsi" ` FileOpen $2 $0 "r"$n`
!appendfile "gfs.nsi" ` FileSeek $2 0 END $1$n`
!appendfile "gfs.nsi" ` FileClose $2$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `; file size is in the $1$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `FunctionEnd$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `Function .onInit$n`
!appendfile "gfs.nsi" ` Call GetParameters$n`
!appendfile "gfs.nsi" ` Call FileSize$n`
!appendfile "gfs.nsi" `; MessageBox MB_OK '$0 $1'$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" ` FileOpen $2 "$EXEDIRgfs.txt" w$n`
!appendfile "gfs.nsi" ` FileWrite $2 '!echo "File Size: $0"`
!appendfile "gfs.nsi" `$`
!appendfile "gfs.nsi" ``
!appendfile "gfs.nsi" `r`
!appendfile "gfs.nsi" `$`
!appendfile "gfs.nsi" ``
!appendfile "gfs.nsi" `n`
!appendfile "gfs.nsi" `!define FILESIZE $1'$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" ` FileClose $2$n`
!appendfile "gfs.nsi" ` Abort$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `FunctionEnd$n`
!appendfile "gfs.nsi" `$n`
!appendfile "gfs.nsi" `Section$n`
!appendfile "gfs.nsi" `SectionEnd$n`
!system "${NSISDIR}makensis.exe gfs.nsi"
!system "gfs.exe ${FILENAME}"
!include "gfs.txt"
Section "NSIS衿华客"
 SetOutPath "$TEMP"
 Delete "${FILENAME}"
 fsp::track /nounload "/fn=${FILENAME}" /fs=${FILESIZE} /int=300 /pbf=50
 File "${FILENAME}"
 Sleep 2000
 fsp::stop
 fsp::track /nounload "/fn=${FILENAME}" /fs=${FILESIZE} /int=300 /pbf=50
 File "${FILENAME}"
 Sleep 2000
 fsp::stop
SectionEnd
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » FSP是NSIS根据文件大小动态控制进度条的插件

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址