欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Delphi實(shí)現(xiàn)限定軟件使用時(shí)間的方法

 更新時(shí)間:2014年07月24日 11:10:15   投稿:shichen2014  
這篇文章主要介紹了Delphi實(shí)現(xiàn)限定軟件使用時(shí)間的方法,商業(yè)軟件開發(fā)中非常實(shí)用的功能,需要的朋友可以參考下

我們經(jīng)常看到很多網(wǎng)上下載的試用版軟件,都有使用時(shí)間的限制,就其商業(yè)角度而言也是處于軟件效益保護(hù)的一種措施,可以讓用戶免費(fèi)試用一段時(shí)間,若滿意就可以購(gòu)買商業(yè)軟件。本文所述實(shí)例代碼功能就是如何為Delphi所編寫的程序添加使用時(shí)間的限制功能,這里默認(rèn)的時(shí)限為30天。

主要代碼如下:

unit Unit1;
interface
uses
 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;
    //判斷是否初次運(yùn)行程序
    if OpenKey('Software\MySoftware',True) then
    begin
      if ReadBool('Runned') then
      //不是第一次運(yùn)行
      begin
        curDate := Date;
        if (curDate-ReadTime('LastRunTime'))>=ReadInteger('Duration') then
        begin
          //當(dāng)前的系統(tǒng)時(shí)間超出了使用期限
          ShowMessage('試用版已到期');
          exit;
        end
        else
        begin
          DeleteKey('LastRunTime');
          WriteTime('LastRunTime',Date);
        end;
      end
      else
      begin
        //初次運(yùn)行程序
        DeleteKey('Runned');
        WriteBool('Runned',True);
        //設(shè)置試用期限30天
        WriteInteger('Duration',30);
        //寫入當(dāng)前運(yùn)行時(shí)間
        WriteTime('LastRunTime',Date);
      end;
    end
    else
    begin
      ShowMessage('Fails!');
    end;
    CloseKey;
  end;
end;
end.

相關(guān)文章

最新評(píng)論