• 网站导航

限速工具实现代码(联通卡取消限速代码)

更新时间:2021-09-18 11:43:12 来源:  网络
近期可能很多人都在关注限速工具实现代码相关的内容,今日小编也是在网上找了很多关于 限速工具实现代码 相关信息并整理如下,希望对大家有所帮助:

使用软件次数限制,如果用户不是经常打开软件,那么用户可能会很长时间以后才会购买。还有可能就是软件用户为了延长使用时间,打开一次以后很长时间才关闭,这样也造成了用户会很长时间以后才购买软件。为了防止这些情况出现,可以采用软件试用天数来进行限制。

软件试用天数限制就是指用户从第一次打开软件的那天开始往后累加,一直到指定的试用天数,超过了就提示试用期已到。同样,设置试用天数也不能设置得太长,如15天以上,也不能设置太短,如7天以下,推荐设置为7~15天,包括7天和15天。软件试用天数信息也可以保存到文件或是注册表中,保存的时候需要加密。

实现软件试用天数的步骤如下:


限速工具实现代码(联通卡取消限速代码)

1) 软件启动时,从注册表或文件中读取信息,如为空,则将系统日期写入到键SoftWareData中,同时天数赋值为1(SoftWareCount),软件继续运行。写入两个值的目的是防止用户调整计算机日期。

2) 如果读取到信息不为空,需对比当前系统日期和SoftWareData对比。

a) 当前系统日期<SoftWareData的日期,说明用户调整过系统日期,终止执行;

b) 当前系统日期=SoftWareData,说明当天为软件最后试用日期。

c) 当前系统日期>SoftWareData时,取SoftWareCount(天数)的值。

i. SoftWareCount > 软件试用天数,提示用户试用日期已到且软件终止运行;

ii.SoftWareCount < 软件试用天数,将当前日期更新到SoftWareData中,同时SoftWareCount = (当前系统日期-SoftWareData)+原SoftWareCount值。 

实现软件试用天数的完整示例代码如下:

unit TrialDate;interfaceuses Base64Unit,System.Win.Registry,Winapi.Windows,System.SysUtils, System.Classes,Vcl.Controls;function TrialDate(TrialInt:Integer):Integer;implementation//==============================================================================// 软件试用天数设置——写入到注册表中// 作者:键盘记忆//日期:2021年4月29日23点34分//==============================================================================function TrialDate(TrialInt:Integer):Integer;var Reg:TRegistry; RegStr,TempStr:String; CountInt:Integer; MyCount:Double; begin RegStr := ''; TempStr := ''; CountInt := 0; MyCount:= 0; try Reg := TRegistry.Create; //创建对象 Reg.RootKey := HKEY_CURRENT_USER; RegStr := 'SoftwareTrial'; if Reg.OpenKey(RegStr,False) then TempStr := Reg.ReadString('TrialDate'); Reg.CloseKey; if TempStr = '' then //第一次试用 begin if Reg.OpenKey(RegStr,True) then begin Reg.WriteString('TrialDate',Base64Encryption(DateToStr(Date))); Reg.WriteString('TrialCount',Base64Encryption('1')); end; Reg.CloseKey; Result := 1; end else begin //当前系统日期<TrialDate ,试用日期已经到了 if Date<StrToDate(Base64Decryption(TempStr)) then begin if Reg.OpenKey(RegStr,False) then Reg.WriteString('TrialCount',Base64Encryption(IntToStr(TrialInt))); Reg.CloseKey; Result := 0; Exit; end; if Reg.OpenKey(RegStr,False) then CountInt := StrToInt(Base64Decryption(Reg.ReadString('TrialCount'))); Reg.CloseKey; //如果TrialDate=当前系统日期,最后试用日期为当天 if Date = StrToDate(Base64Decryption(TempStr)) then begin Result := CountInt; Exit; end; MyCount := Date - StrToDate(Base64Decryption(TempStr)); CountInt := CountInt + Trunc(Mycount); if CountInt > TrialInt then begin if Reg.OpenKey(RegStr,False) then begin Reg.WriteString('TrialDate',Base64Encryption(DateToStr(Date))); Reg.CloseKey; Result := 0; Exit; end; Result := CountInt; if Reg.OpenKey(RegStr,False) then begin Reg.WriteString('TrialDate',Base64Encryption(DateToStr(Date))); Reg.WriteString('TrialCOunt',Base64Encryption(IntToStr(CountInt))); end; Reg.CloseKey; end; Reg.Destroy; end; except on E: Exception do Result := -1; end; end;end.

不论试用信息存储在注册表还是文件,应给予用户两种提示方式:

方式一:“软件试用了几天”;

方式二:“软件还剩多少天”。

以上就是关于限速工具实现代码 相关问题啦,如需了解更多关于限速工具实现代码问题,关注我们的下次更新哦