手机
当前位置:查字典教程网 >编程开发 >Delphi >Delphi实现限定软件使用时间的方法
Delphi实现限定软件使用时间的方法
摘要:我们经常看到很多网上下载的试用版软件,都有使用时间的限制,就其商业角度而言也是处于软件效益保护的一种措施,可以让用户免费试用一段时间,若满意...

我们经常看到很多网上下载的试用版软件,都有使用时间的限制,就其商业角度而言也是处于软件效益保护的一种措施,可以让用户免费试用一段时间,若满意就可以购买商业软件。本文所述实例代码功能就是如何为Delphi所编写的程序添加使用时间的限制功能,这里默认的时限为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; //判断是否初次运行程序 if OpenKey('SoftwareMySoftware',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.

【Delphi实现限定软件使用时间的方法】相关文章:

Delphi实现树型结构具体实例

在Delphi实现在数据库中存取图像的图文演示无错

Delphi中对时间操作方法汇总

Delphi实现窗口文字淡入淡出渐变效果的方法

Delphi7中群发Email邮件的方法

Delphi实现读取系统时间与日期完整实例

delphi建立、读取、存贮INI文件的方法《二》

Delphi下OpenGL2d绘图之画四边形的方法

Delphi实现判断网址是否存在及是否可以打开的方法

Delphi控件ListView的属性及使用方法详解

精品推荐
分类导航