最新消息:

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

nsis 永恒心锁 1810浏览 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
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

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

您必须 登录 才能发表评论!