中文国产日韩欧美视频,午夜精品999,色综合天天综合网国产成人网,色综合视频一区二区观看,国产高清在线精品,伊人色播,色综合久久天天综合观看

軟件試用期及試用次數(shù)控制

時(shí)間:2024-08-31 22:12:12 學(xué)人智庫(kù) 我要投稿
  • 相關(guān)推薦

軟件試用期及試用次數(shù)控制

下面的代碼簡(jiǎn)單演示了各部分的處理過(guò)程:

一、安裝時(shí)寫入加密數(shù)據(jù):

 (這里的加密使用了控件)

DES->GenerateKey(neowarton20030731);

 TDateTime *d=new TDateTime(Date());

 AnsiString times,date,filename;;

 char dir[256];

 times=0;

 date=DateTimeToStr(*d);

 times=DES->EncryptString(times);

 date=DES->EncryptString(date);

 //install=DES->EncryptString(date);

 AnsiString s=times+date;

 OutputDebugString(s.c_str());

 filename=\mysoft.ini;

 GetSystemDirectory(dir,sizeof(dir));

 filename=dir+filename;

if(FileExists(filename))

 {

 Application->Terminate();  //if the ini file is alread exists exit;

 }

 else

 {

 TIniFile *ini=new TIniFile(filename);

 ini->WriteString(setup,times,times);

 ini->WriteString(setup,date,date);

 ini->WriteString(setup,install,date);

ini;

//write register

TRegistry *reg=new TRegistry();

 reg->RootKey=HKEY_LOCAL_MACHINE;

 if(reg->KeyExists(\SOFTWARE\Microsoft\Windows\CurrentVersion\mysoft))

 Application->Terminate();//if the key exists,terminate

 reg->OpenKey(\SOFTWARE\Microsoft\Windows\CurrentVersion\mysoft,true);

 reg->WriteString(warning,dot modify these items!Otherwise,your system will not run!neowarton2003xian);

 reg->WriteString(times,times);

 reg->WriteString(date,date);

 reg->WriteString(install,date);

 reg->CloseKey();

reg;

 }

二、安裝時(shí)在install Shield中加入以下代碼:

 Lauchapp(SUPPORTDIR^test.exe,)  //test為上面代碼的exe文件

 其它代碼省略

三、在應(yīng)用程序起動(dòng)時(shí):

bool rt;

 TForm1 *fm1=new TForm1(NULL);//試用版彈出的窗口,點(diǎn)擊試用返回判斷結(jié)果

 fm1->ShowModal();

 rt=fm1->try_time;//是否已經(jīng)過(guò)期

  fm1;

 if(rt)

 {

 MessageBox(NULL,¥?3n?é??¥?′á¤v1L?A§A¤£ˉà|A¨?¥??óa(chǎn)?¥??A?Dáê?R¥?|?a??I http://www.xxxxx.com ,ˉ?2t¥D?÷o?μ?¨?¤?àe,MB_OK+MB_ICONINFORMATION);

 Application->Terminate();//??3?à3¥?μ{§?

 return 0;

 }

四、用戶點(diǎn)擊試用按鈕,返回是否過(guò)期的bool值:

//read the encrypted ini file in the system directory to read the time and date

 //if filenote exist,return false,if the time and date wrong return false;

//read data and then time from the register,where the data is also encrypted

char dir[256];

 AnsiString filename=\mysoft.ini;

 GetSystemDirectory(dir,sizeof(dir));

//the ini fils is in the system directory

 filename=dir+filename;

 if(!FileExists(filename))

 {

 Application->MessageBox(§Aao¨t2?1?¥?3n¥ó?i|?¤F?Dak-ק??A¤w?g¤£ˉà|A¨?¥??I ,ˉ?2t¥D?÷¨?¤?àe,MB_ICONERROR);

 HWND H;

 H=FindWindow(NULL,DNAAlarm);

 ::SendMessage(H,WM_CLOSE,0,0);

 OutputDebugString(go here);

 this->try_time=true;

 Close();

 return;

 }

TIniFile *ini=new TIniFile(filename);

 AnsiString times,datetime,installday;

times=ini->ReadString(setup,times,);

 datetime=ini->ReadString(setup,date,);

 installday=ini->ReadString(setup,install,);

 getthepara();

AnsiString tt=times_reg+|+datetime_reg+|+datetime_reg;

 AnsiString ttt=times+|+datetime+|+installday;

if((times_reg!=times)||(datetime_reg!=datetime)||(installday!=datetime_reg))

 {

this->try_time=true;

 }

 else  //------------------------------------

 {

DES->GenerateKey(neowarton20030731);

 times=DES->DecryptString(times);

 datetime=DES->DecryptString(datetime);

 installday=DES->DecryptString(installday);

times_reg=DES->DecryptString(times_reg);

 datetime_reg=DES->DecryptString(datetime_reg);

 installday_reg= DES->DecryptString(installday_reg);

tt=times_reg+|+datetime_reg+|+datetime_reg;

 ttt=times+|+datetime+|+installday;

 //|r2?|ê?à′?|¨¤é′á

 int t=StrToInt(times);

 TDateTime *dt=new TDate(Date());

TDateTime *s=new TDate(StrToDate(datetime));  TDateTime *install=new TDate(StrToDate(installday));

int tmp=*dt-*s;  

 int tmp2=*dt-*install;

 //int tmp3=*s-*dt;

if((tmp>=-1)&&(tmp<=90)&&(tmp2>=-1)&&(tmp2<=90)&&(t<150))

{

 AnsiString times_tmp=DES->EncryptString(IntToStr(StrToInt(times)+1));

 AnsiString datetime_tmp=DES->EncryptString(DateTimeToStr(*dt));  

 ini->WriteString(setup,times,times_tmp);

 ini->WriteString(setup,date,datetime_tmp);

 putthepara(times_tmp,datetime_tmp);

 this->try_time=false;

 }

 else

 {

 //write wrong time;

 

 AnsiString times_tmp=DES->EncryptString(IntToStr(StrToInt(times)+200));

 AnsiString datetime_tmp=DES->EncryptString(DateTimeToStr(*dt+3000));  

 ini->WriteString(setup,times,times_tmp);

 ini->WriteString(setup,date,datetime_tmp);

 putthepara(times_tmp,datetime_tmp);

 this->try_time=true;

 }

 }

ini;

this->Close();

五、ini文件:

[setup]

times=inAk6xcTevw=

date=XOqvDla+r+2Xtl4ZM567cQ==

install=kAP2X5LVcWaXtl4ZM567cQ==

(數(shù)據(jù)已經(jīng)加密)

.....

六、注表容INI文件容基本相同!

上面的代碼只是初步的,如果你要使用,需要經(jīng)過(guò)詳細(xì)的修改才對(duì)。由于是繁體版,部分注釋顯示為亂碼,我已經(jīng)將注釋刪除了,里面的消息框里的字符串也是亂碼,可以改改就行!敬原!

(注,本文只是推薦一種簡(jiǎn)單的方法,以滿足在些朋友簡(jiǎn)單的要求,代碼剛實(shí)現(xiàn)功能 ,存在很多問(wèn)題,我才準(zhǔn)備改改,有好的方法可以提出來(lái)。┯蠹姨崾竞玫姆椒ā

[軟件試用期及試用次數(shù)控制]

【軟件試用期及試用次數(shù)控制】相關(guān)文章:

母乳的喂養(yǎng)次數(shù)08-02

試用期自我評(píng)價(jià)精選11-08

試用期自我評(píng)價(jià)06-24

試用期的自我評(píng)價(jià)09-21

試用期實(shí)習(xí)心得09-02

試用期述職報(bào)告09-28

試用期述職報(bào)告09-18

試用期自我評(píng)價(jià)08-08

試用期的自我評(píng)價(jià)08-28

員工試用期總結(jié)06-08