2010-03-09 2 views
4

NSIS을 사용하여 설치 프로그램을 개발했습니다. 응용 프로그램을 다시 설치할 때마다 기존 데이터베이스 파일의 백업을 만들고 싶습니다.NSIS를 사용하여 파일 이름으로 현재 날짜와 시간 쓰기

'currentdatetime'형식을 사용하여 데이터베이스 파일의 이름을 어떻게 바꿀 수 있습니까 (예 : 201003101140은 오전 11시 40 분에 2010-03-10을 의미)?

감사합니다.

답변

5
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" 
8

이 호출에 대한 NSIS의 내장 함수가 $ {GetTime에}

!include "FileFunc.nsh" 
    !insertmacro GetTime 

    ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6 
    DetailPrint "currentdatetime=$2$1$0$4$5$6" 

이 출력됩니다 뭔가

같은
currentdatetime=20130210205537 

"10-02 월 20:55:37"을 의미합니다.

0

이 작업을 수행하는 가장 좋은 방법은 여기에 설명 : nsis !define /date MyTIMESTAMP "%Y-%m-%d-%H-%M-%S" Name "MyApplicationName ${MyTIMESTAMP}" OutFile "MyApplicationNameSetup-${MyTIMESTAMP}.exe"