我使用NSIS开发了一个安装程序.每次我重新安装应用程序时,我都想创建现有数据库文件的备份.
如何使用以下格式"currentdatetime"重命名这些数据库文件(例如:201003101140表示2010-03-10上午11:40)?
谢谢 !
Pau*_*sen 14
这个名为$ {GetTime}的NSIS中有一个内置函数
!include "FileFunc.nsh"
!insertmacro GetTime
${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
DetailPrint "currentdatetime=$2$1$0$4$5$6"
Run Code Online (Sandbox Code Playgroud)
这将输出类似的东西
currentdatetime=20130210205537
Run Code Online (Sandbox Code Playgroud)
意思是"10-Feb-2013 20:55:37".
System::Call '*(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2)i.s'
System::Call /NOUNLOAD 'kernel32::GetLocalTime(isr0)'
System::Call '*$0(&i2.r1,&i2.r2,&i2,&i2.r3,&i2.r4,&i2.r5,&i2,&i2)'
System::Free $0
IntFmt $1 "%0.4d" $1
IntFmt $2 "%0.2d" $2
IntFmt $3 "%0.2d" $3
IntFmt $4 "%0.2d" $4
IntFmt $5 "%0.2d" $5
DetailPrint "datetime=$1$2$3$4$5"
Run Code Online (Sandbox Code Playgroud)