最新消息:

BgWorker为NSIS提供多线程支持

nsis 永恒心锁 3404浏览 0评论
/*
BgWorker.dll插件为NSIS提供多线程支持,特别是在自定义界面进行进度条操作时常要用到的插件.
*/
!AddPluginDir "../Plugins"
OutFile "BgWorker.exe"
SetCompressor /SOLID lzma
!include "nsDialogs.nsh"
!include "FileFunc.nsh"
!define secondsofwork 10
Page custom page1.create
Function Func3
 #${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
 #SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:$4:$5:$6"
FunctionEnd
Function Func2
 System::Call kernel32::GetTickCount()i.r1
 loop:
 System::Call kernel32::GetTickCount()i.r2
 IntOp $2 $2 - $1
 IntOp $3 1000 * ${secondsofwork}
 IntOp $4 100 * $2
 IntOp $4 $4 / $3
 ${If} $4 <> $5
 StrCpy $5 $4
 ${NSD_SetText} $8 "Working... ($4%)"
 ${EndIf}
 IntCmp $2 $3 0 loop
FunctionEnd
Function Func2_
 GetFunctionAddress $0 Func2_
 nsDialogs::KillTimer $0
 !if 1 ;do work in background thread?
 GetFunctionAddress $0 Func2
 BgWorker::CallAndWait
 !else
 call Func2
 !endif
 SetCtlColors $8 0x007700 transparent
 ${NSD_SetText} $8 "Work completed"
 System::Call "user32::InvalidateRect(i $hwndparent,i0,i 1)"
FunctionEnd
Function Func1
 System::Call kernel32::GetTickCount()i.r1
 loop:
 System::Call kernel32::GetTickCount()i.r2
 IntOp $2 $2 - $1
 IntOp $3 1000 * ${secondsofwork}
 IntOp $4 100 * $2
 IntOp $4 $4 / $3
 ${If} $4 <> $5
 StrCpy $5 $4
 ${NSD_SetText} $9 "Working... ($4%)"
 ${EndIf}
 IntCmp $2 $3 0 loop
FunctionEnd
Function Func1_
 GetFunctionAddress $0 Func1_
 nsDialogs::KillTimer $0
 !if 1 ;do work in background thread?
 GetFunctionAddress $0 Func1
 BgWorker::CallAndWait
 !else
 call Func1
 !endif
 SetCtlColors $9 0x007700 transparent
 ${NSD_SetText} $9 "Work completed"
 System::Call "user32::InvalidateRect(i $hwndparent,i0,i 1)"
FunctionEnd
Function page1.create
 nsDialogs::Create 1018
 Pop $0
 ${NSD_CreateLabel} 0 0 100% 10u "Working..."
 Pop $9
 SetCtlColors $9 0x0000FF 0xFFFFFF
 ${NSD_CreateLabel} 0 50 100% 10u "Working..."
 Pop $8
 SetCtlColors $8 0x0000FF 0xFFFFFF
 GetFunctionAddress $1 Func1_
 nsDialogs::CreateTimer $1 100
 GetFunctionAddress $1 Func2_
 nsDialogs::CreateTimer $1 100
 GetFunctionAddress $1 Func3
 nsDialogs::CreateTimer $1 100
 nsDialogs::Show
FunctionEnd
Section "永恒心锁"
SectionEnd
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » BgWorker为NSIS提供多线程支持

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