大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 程序开发 -> 在Delphi中编制软件版权保护控件

在Delphi中编制软件版权保护控件

时间: 2021-07-31 作者:daque

一、概括 软硬件动作一种生人才华处事功效的一种展现情势,领会了安排者和开拓者发愤的处事和汗水,但是,因为用户看法上的分别和盗版软硬件的弥漫,软硬件开拓者的权力常常得不到灵验的养护,所以,动作需要的本领-----软硬件的自己养护也就在一定的情况下被关心起来。 但是,正所谓,“魔高级中学一年级尺,道高级中学一年级丈”,养护和破译的冲突联系在一直连接着,要想找到一种全能的养护本领,却也不是那么大略的事。然而,即使开拓者运用的养护本领连普遍用户都能破译的话(如:窜改体例日子),如许的养护则明显达不到养护软硬件版权的手段。 鉴于此,笔者运用delphi5.0面向东西的个性,安排开拓了一个适用的版权养护控件,觉得步调开拓者供给一种简略的软硬件养护本领。 二、实行本领 1.在delphi5.0中兴建一个单位文献,抄写代码如次,生存: unit regobj; interface uses windows, messages, sysutils, classes, forms; type tregobj = class private fserial: string; //主板序列号 fkey: string; //暗号 fmaxtimes: integer; //最大运转度数 fcompany: string; //公司称呼 femail: string; //接洽用的电子邮件 protected procedure setserial; //博得主扳的序列号 procedure getkey; //从用户序列号文献中读取序列号 function gettimes: integer; //从文献中读取步调的运转度数 function checkkey: boolean; //查看序列号和暗号能否配合的因变量 public constructor create; function execute: boolean; //运转东西本领 published property company: string read fcompany write fcompany; property maxtimes: integer read fmaxtimes write fmaxtimes; property email: string read femail write femail; end; implementation //tregobj. constructor tregobj.create; begin inherited; end; function tregobj.gettimes: integer; const //用来保存运转度数的文献,开拓职员可自设置或运用备案表保存运转度数 //起此名字用来迷惘破译者,运用前不要和体例的动静链接库同名 tmp = 'ispnet.dll'; var ch: char; dir: array [0..255] of char; fn: string; i : integer; list: tstrings; begin //博得windows体例的目次 getsystemdirectory(@dir, 255); for i := 0 to 255 do begin if ord(dir[i]) = 0 then break; fn := fn + dir[i]; end; fn := fn + '\' + tmp; try list := tstringlist.create; if not fileexists(fn) then ch := chr(1) else begin list.loadfromfile(fn); ch := list.text[1]; ch := chr(ord(ch) + 1); end; list.text := ch; //保存运转度数 list.savetofile(fn); result := ord(ch); finally list.free; end; end; procedure tregobj.setserial; begin //博得主板的序列号 fserial := string(pchar(ptr($fec71))); end; //博得暗号 procedure tregobj.getkey; const sn = 'key.dat'; var list: tstrings; fn, path: string; begin path := extractfilepath(application.exename); fn := path + sn; if not fileexists(fn) then begin fkey := ''; exit; end; try list := tstringlist.create; list.loadfromfile(fn); fkey := list.values['key']; finally list.free; end; end; function tregobj.checkkey: boolean; begin //开拓职员按照本人的须要举行窜改,在这边是为了大略起见 result := fkey = fserial; end; function tregobj.execute: boolean; var msg: string; t: integer; begin t := gettimes; getkey; setserial; if fkey <> fserial then begin msg := ' 您这是第' + inttostr(t) + '次运转此步调(最大度数:' + inttostr(fmaxtimes) + ')!'; application.messagebox(pchar(msg), '用户消息', mb_ok + mb_iconwarning); msg := '欢送运用' + company + '的软硬件,即使您感触合意的话,请备案或购置正版软硬件!'; application.messagebox(pchar(msg), '倡导', mb_ok + mb_iconinformation); if t > fmaxtimes then begin if application.messagebox(' 能否备案?', '备案', mb_yesno + mb_iconquestion) = id_yes then begin msg := '您的备案号是:“' + fserial + '”' + chr(13) + chr(10) + '请您将之上序列号经过电子邮件寄赐与下邮箱:' + femail; application.messagebox(pchar(msg), '软硬件 备案', mb_ok + mb_iconinformation); end; application.terminate; end; end; end; end. 2.控件的运用 在delphi5.0中兴建一个运用步调,在步调的援用单位中介入上述单位的援用,在主窗体的oncreate事变中编写如次代码: procedure tform1.formcreate(sender: tobject); var aobj: tregobj; begin try aobj := tregobj.create; aobj.maxtimes := 30; aobj.company := '吉星软硬件处事室'; aobj.email := 'test@1112.net'; aobj.execute; finally aobj.free; end; end; 三、中断语 上述控件经过博得用户计划机的主板序列号动作备案码,经过文献保存步调运转度数和密钥,提防了同样的备案码和密钥在各别的计划机上都不妨运用的题目,并且,用户经过大略的日子窜改没辙使步调连接,基础到达了软硬件版权养护的手段。

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.