NSIS限制程序运行次数和使用日期
#七八年前写着玩的小东西,实际用途不大,但对刚接触nsis的新手来说应该还有一些帮助,包括创建控件,获取系统时间等,与诸位共勉!
!system '>blank set/p=MSCF<nul'
!packhdr temp.dat 'cmd /c Copy /b temp.dat /b +blank&&del blank'
SetCompressor bzip2
#编写:水晶石
#限制程序运行次数和使用日期
!include "nsdialogs.nsh"
XPStyle on
BrandingText "水晶石 ${__DATE__}"
OutFile "NSIStest.exe"
Name "test"
Page Custom page.custom
Function page.custom
nsDialogs::Create 1018
Pop $0
nsDialogs::CreateControl EDIT \
"${__NSD_Text_STYLE}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN}" \
"${__NSD_Text_EXSTYLE}" \
0 10% 100% 80% \
"有效运行次数:3 $\r$\n$\r$\n首次运行后第二天报错禁止使用。$\r$\n$\r$\n第$1次运行"
Pop $0
nsDialogs::Show
FunctionEnd
Section "test"
SectionEnd
Function .onInit
System::Alloc 16
System::Call "kernel32::GetLocalTime(isR0)"
System::Call "*$R0(&i2.R1,&i2.R2,&i2.R3,&i2.R4)"
System::Free $R0
StrCpy $3 $R1 $R2 $R4
ReadRegStr $2 SHCTX "Software\Microsoft\test" "time"
${if} $2 = ''
StrCpy $2 $3
WriteRegStr SHCTX "Software\Microsoft\test" "time" "$2"
${endif}
IntOp $4 $2 + 1
${if} $4 <= $3
System::Call "user32::MessageBox(i $HWNDPARENT, t 'Installer integrity check has failed.\
Common causes include $\r\
incomplete download and damaged media.Contactthe $\r\
installer is author to obtain a new copy.$\r$\r\
More information at: $\r\
https://blog.csdn.net/shuijing_0'\
,t 'NSIS Error', i0x10)"
Quit
${endif}
ReadRegStr $1 SHCTX "Software\Microsoft\test" 'Number'
IntOp $1 $1 + 1
WriteRegStr SHCTX "Software\Microsoft\test" "Number" "$1"
${if} $1 > 3
System::Call "user32::MessageBox(i $HWNDPARENT, t 'Installer integrity check has failed.\
Common causes include $\r\
incomplete download and damaged media.Contactthe $\r\
installer is author to obtain a new copy.$\r$\r\
More information at: $\r\
https://blog.csdn.net/shuijing_0'\
,t 'NSIS Error', i0x10)"
Quit
${endif}
FunctionEnd
本文来自博客园,作者:水晶石,转载请注明原文链接:https://www.cnblogs.com/NSIS/p/16581125.html