//===================================================
//Create by Leio 2005/09/29
//限制使用期限
//如果没有test.ini文件则认为是第一次使用.
integer li_filenum
if not fileexists('test.ini') then
//第一次使用
messagebox('欢迎','欢迎使用本系统,您可以试用90天,试用期将在'+&
string(relativedate(today(),90))+'到期!')
li_filenum = FileOpen("test.ini",StreamMode!,Write!,LockWrite!, Replace!)
fileclose(li_filenum)
setprofilestring('test.ini','register','firstdate',string(today(),'yyyy/mm/dd'))
setprofilestring('test.ini','register','firsttime',string(now(),'hh:mm:ss'))
setprofilestring('test.ini','register','usedate',string(today(),'yyyy/mm/dd'))
setprofilestring('test.ini','register','usetime',string(now(),'hh:mm:ss'))
open(w_main)
return
end if
datetime ldt_now,ldt_savevalue,ldt_first
//系统当前时间
ldt_now = datetime(today(),now())
//第一次使用的时间
ldt_first = datetime(date(profilestring('test.ini','register','firstdate','2000/01/01')),&
time(profilestring('test.ini','register','firsttime','00:00:00')))
//上一次使用的时间
ldt_savevalue = datetime(date(profilestring('test.ini','register','usedate','2000/01/01')),&
time(profilestring('test.ini','register','usetime','00:00:00')))
long ll_second,ll_days
//用当前时间与上一次启动的时间进行比较
ll_days = daysafter(date(ldt_savevalue),date(ldt_now))
if ll_days = 0 then//上次启动是同一天
ll_second = secondsafter(time(ldt_savevalue),time(ldt_now))
elseif ll_days > 1 then//上次启动是多天以前
ll_second = 9999
elseif ll_days < 0 then//上次启动日期大于当前日期,日期被修改了
ll_second = -999
else
ll_second = -999
end if
if ll_second < 0 then
messagebox('提示','系统时间发生异常,按确定退出系统!',StopSign!)
//系统日期时间被改回较早的日期时间
halt close
return
else
//判断是否到期
ll_days = daysafter(date(ldt_first),date(ldt_now))
if ll_days > 90 then
messagebox('提示','使用期限已到!')
halt close
return
end if
end if
//更新test.ini为当前时间
setprofilestring('test.ini','register','usedate',string(today(),'yyyy/mm/dd'))
setprofilestring('test.ini','register','usetime',string(now(),'hh:mm:ss'))
open(w_main)
//=================================================