Delphi實現(xiàn)限定軟件使用時間的方法
更新時間:2014年07月24日 11:10:15 投稿:shichen2014
這篇文章主要介紹了Delphi實現(xiàn)限定軟件使用時間的方法,商業(yè)軟件開發(fā)中非常實用的功能,需要的朋友可以參考下
我們經(jīng)常看到很多網(wǎng)上下載的試用版軟件,都有使用時間的限制,就其商業(yè)角度而言也是處于軟件效益保護的一種措施,可以讓用戶免費試用一段時間,若滿意就可以購買商業(yè)軟件。本文所述實例代碼功能就是如何為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('Software\MySoftware',True) then
begin
if ReadBool('Runned') then
//不是第一次運行
begin
curDate := Date;
if (curDate-ReadTime('LastRunTime'))>=ReadInteger('Duration') then
begin
//當前的系統(tǒng)時間超出了使用期限
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.
相關文章
為什么繼續(xù)選擇DELPHI(即將逝去的Delphi前景在何方)
已經(jīng)鉆DELPHI很深了,當然現(xiàn)在DELPHI是過了最輝煌的時代。但為什么要繼續(xù)下去,而不轉向其它的?這是不是死腦筋2018-02-02
在Delphi實現(xiàn)在數(shù)據(jù)庫中存取圖像的圖文演示無錯
最近打算學習Delphi實現(xiàn)在數(shù)據(jù)庫中存取圖像,網(wǎng)上的好多Delphi實現(xiàn)在數(shù)據(jù)庫中存取圖像都是錯誤的,所以我把圖片給弄好了。2008-01-01
wordpress主題支持自定義菜單及修改css樣式實現(xiàn)方法
使用wordpress過程中會遇到主題支持自定義菜單以及修改css樣式問題,本文將介紹詳細解決方法,需要朋友可以參考下2012-12-12
Delphi實現(xiàn)窗體感知鼠標滑過并自動隱藏與顯示窗口的方法
這篇文章主要介紹了Delphi實現(xiàn)窗體感知鼠標滑過并自動隱藏與顯示窗口的方法,涉及Delphi操作窗口及鼠標事件的技巧,需要的朋友可以參考下2015-05-05

