国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

Delphi實現限定軟件使用時間的方法

2020-01-31 20:51:09
字體:
來源:轉載
供稿:網友

我們經??吹胶芏嗑W上下載的試用版軟件,都有使用時間的限制,就其商業角度而言也是處于軟件效益保護的一種措施,可以讓用戶免費試用一段時間,若滿意就可以購買商業軟件。本文所述實例代碼功能就是如何為Delphi所編寫的程序添加使用時間的限制功能,這里默認的時限為30天。

主要代碼如下:

unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Registry, Dialogs;type TForm1 = class(TForm)  procedure FormCreate(Sender: TObject); private  { Private declarations } public  { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);var  registerTemp : TRegistry;  curDate : TDateTime;begin  registerTemp := TRegistry.Create;  with registerTemp do  begin    RootKey := HKEY_LOCAL_MACHINE;    //判斷是否初次運行程序    if OpenKey('Software/MySoftware',True) then    begin      if ReadBool('Runned') then      //不是第一次運行      begin        curDate := Date;        if (curDate-ReadTime('LastRunTime'))>=ReadInteger('Duration') then        begin          //當前的系統時間超出了使用期限          ShowMessage('試用版已到期');          exit;        end        else        begin          DeleteKey('LastRunTime');          WriteTime('LastRunTime',Date);        end;      end      else      begin        //初次運行程序        DeleteKey('Runned');        WriteBool('Runned',True);        //設置試用期限30天        WriteInteger('Duration',30);        //寫入當前運行時間        WriteTime('LastRunTime',Date);      end;    end    else    begin      ShowMessage('Fails!');    end;    CloseKey;  end;end;end.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 依兰县| 新营市| 神木县| 通山县| 马尔康县| 朝阳市| 临邑县| 吴旗县| 嘉祥县| 广元市| 永城市| 堆龙德庆县| 高清| 逊克县| 阿瓦提县| 大同市| 兴安盟| 贞丰县| 田林县| 梅河口市| 鹤岗市| 黔南| 威远县| 绍兴县| 千阳县| 于田县| 华池县| 汉沽区| 宜宾县| 黄山市| 库车县| 永靖县| 宣恩县| 宣威市| 麦盖提县| 莒南县| 璧山县| 防城港市| 海丰县| 宁强县| 喜德县|