nsis GetTime安装日期存储在Windows注册表中

时间:2013-09-07 01:14:56

标签: nsis

NSIS

安装程序时 安装日期存储在Windows注册表中

Section
${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
; $0="01" day
; $1="04" month
; $2="2006" year
; $3="Friday" day of week name
; $4="16" hour
; $5="05" minute
; $6="50" seconds

WriteRegStr HKLM "Software\MyApp" "year" "$2"
WriteRegStr HKLM "Software\MyApp" "month" "$1"
WriteRegStr HKLM "Software\MyApp" "day" "$0"

${EndIf}

SectionEnd

我不知道如何运行以下命令:

从注册表中继续阅读>计算>消息plz更新后30天

保存要读取的文件时,程序将从上次录制的警告开始运行1个月

您能帮忙提供示例代码吗

抱歉,我的英语很差

请帮帮我,我是业余

非常感谢......

1 个答案:

答案 0 :(得分:0)

!include LogicLib.nsh

#support.microsoft.com/kb/188768
!define WFT_SEC 10000000
!define WFT_DAY 864000000000

var /GLOBAL installTime
var /GLOBAL expiredTime
var /GLOBAL currentTime

System::Call kernel32::GetSystemTimeAsFileTime(*l.s)
System::Call kernel32::FileTimeToLocalFileTime(*ls,*l.s)
Pop $currentTime

ReadRegStr $installTime HKCU "Software\MyCompany\MyApp" "InstallTime"
${If} $installTime = 0
    StrCpy $installTime $currentTime
    WriteRegStr HKCU "Software\MyCompany\MyApp" "InstallTime" $installTime
${EndIf}

System::Int64Op ${WFT_DAY} * 30 ; You could calculate this with calc.exe if it is always 30 days
Pop $0
System::Int64Op $installTime + $0
Pop $expiredTime


DetailPrint $$currentTime=$currentTime
DetailPrint $$installTime=$installTime
DetailPrint $$expiredTime=$expiredTime
System::Int64Op $currentTime > $expiredTime
Pop $0
DetailPrint "30 days after $$installTime: $0"