SQLCA.DBMS =ProfileString("sn2012.ini", "DataBase", "SQLCA.DBMS", "")
SQLCA.Database = ProfileString("sn2012.ini", "DataBase", "SQLCA.Database", "")
SQLCA.ServerName = ProfileString("sn2012.ini", "DataBase", "SQLCA.ServerName", "")
SQLCA.LogId = ProfileString("sn2012.ini", "DataBase", "SQLCA.LogId", "")
SQLCA.LogPass = ProfileString("sn2012.ini", "DataBase", "SQLCA.LogPass", "")
SQLCA.AutoCommit = False
SQLCA.DBParm = ProfileString("sn2012.ini", "DataBase", "SQLCA.DBParm", "")
string ls_reg_type
ls_reg_type=ProfileString("sn2012.ini", "sys_reg", "reg_type", "")
connect using sqlca;
if sqlca.sqlcode<>0 then
MessageBox ("提示信息", "不能连接数据库:" + sqlca.sqlerrtext)
else
string disksn
string instr
string outstr
boolean r
string ls
string ls_id
string ls_false_sn
string ls_true_sn
long ll_size
string temp_id
string temp_sn
string computerid
date date1
date date2
int free_date
//读取本机信息
disksn=space(100)
GetDiskSN(0,ref disksn)
computerid=space(16)
GetComputerID(ref computerid, 16)
/**********************试用版插入信息************************/
//试用注册码
select reg_id,reg_sn into :temp_id,:temp_sn from sys_reg where reg_type=:ls_reg_type;
//判断
if temp_id= "" then
/***********************************/
//试用注册码
ls_id=string(relativedate(today(),30),'YYYYMMDD')
ll_size = b64_size(LenA(disksn),1)
ls_false_sn= Space(ll_size)
b64_des(disksn,ls_false_sn,ls_id,LenA(disksn),1)
/***********************************/
insert into sys_reg (reg_type,reg_id,reg_sn)values(:ls_reg_type,:ls_id,:ls_false_sn);
commit;
open(login_win)
else
ll_size = b64_size(LenA(disksn),1)
ls_false_sn= Space(ll_size)
b64_des(disksn,ls_false_sn,temp_id,LenA(disksn),1)
/***********************************/
//正式注册码
ls_id=temp_id
ll_size = b64_size(LenA(computerid),1)
ls_true_sn= Space(ll_size)
b64_des(computerid,ls_true_sn,ls_id,LenA(computerid),1)
//读取数据库注册信息
/***********************************/
choose case temp_sn
case ls_false_sn
date1=date(today())
date2=date(left(ls_id,4) + '-' + mid(ls_id,5,2) + '-' + right(ls_id,2))
free_date=DaysAfter(date1,date2)
if free_date>0 then
messagebox('提示','试用版本还有'+string(free_date)+'天')
open(login_win)
else
messagebox('提示','试用期已过!请联系供应商')
open(sys_reg)
end if
case ls_true_sn
open(login_win)
end choose
end if
end if