📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, ImgList, ExtCtrls,ShellAPI,Registry;
type
TForm1 = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ImageList1: TImageList;
Timer1: TTimer;
ToolButton3: TToolButton;
tmr1: TTimer;
procedure ToolButton4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure tmr1Timer(Sender: TObject);
private
aatom:atom;
VideoButton,EndButton:THandle;
VideoX,VideoY:integer;
EndButtonVisible:Boolean;
procedure hotkey(var msg:tmessage);message wm_hotkey;
function Encrypt(TempStr: string): string;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.ToolButton4Click(Sender: TObject);
begin
if ToolButton4.Down then
begin
aatom:=globaladdatom('hot keyF12');
RegisterHotKey(handle,aatom,MOD_ALT,vk_f12);
aatom:=globaladdatom('hot keyF11');
RegisterHotKey(handle,aatom,MOD_ALT,vk_f11);
VideoButton:=0;
EndButton:=0;
end
else
begin
UnregisterHotKey(Handle, GlobalAddAtom('hot keyF12'));
UnregisterHotKey(Handle, GlobalAddAtom('hot keyF11'));
end;
end;
procedure TForm1.hotkey(var msg:tmessage);
var
rPos:TPoint;
hwnd:THandle;
Rect:TRect;
begin
if (msg.LParamHi=VK_F12) and (msg.LParamLo=MOD_ALT) then
begin
//抓捕结束按钮
GetCursorPos(rPos);
EndButton := WindowFromPoint(rPos);
end;
if (msg.LParamHi=VK_F11) and (msg.LParamLo=MOD_ALT) then
begin
//抓捕点击视频
GetCursorPos(rPos);
VideoButton := WindowFromPoint(rPos);
GetWindowRect(VideoButton,Rect);
VideoX:=rPos.X-Rect.Left;
VideoY:=rpos.y-Rect.top;
rPos.X:=VideoX;
rPos.Y:=VideoY;
end;
end;
function TForm1.Encrypt(TempStr:string):string;
var
Str1:String;
i,j:Integer;
begin
Str1:='';
for i:=1 to Length(TempStr) do
begin //密码匹配方式
j:=(i*i*i*i mod (i+30))+(i*i mod (i+20))+i*3+1;
Str1:=Str1+chr(ord(TempStr[i])+j);
end;
Result:=Str1;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Reg:Tregistry; //自定义注册表变量
NowDate,FirstDate,SpareDays:TDateTime;//自定义时间变量
KeyName,TempCode,TempName,TempStr:string; //自定义字符串变量
Same:Integer; //自定义整数变量
NumberOfDays:Real;
NoRegistry:Boolean;
begin
NoRegistry:=true;
NowDate:=date; //取得运行时系统日期
try
//创建注册表,有该键则读取,无则创建
Reg:=Tregistry.Create ;
Reg.RootKey :=Hkey_local_machine;
KeyName:='Software\QQ';
if Reg.OpenKey(KeyName,true) then
begin
TempName:=Reg.ReadString('UsrName');
TempCode:=Reg.ReadString('Passwd');
//读取用户名,注册号
try
FirstDate:=Reg.ReadDate('Date');
//非第一次则读入第一次运行时间
except
FirstDate:=NowDate;
Reg.WriteDate('Date',NowDate);
//若为第一次运行,则写入系统日期
end;
end;
Reg.CloseKey;
finally
Reg.Free;
end;
TempStr:=Encrypt(TempName);
//通过自定义函数Encrypt()来获取密码
Same:=CompareText(TempStr,TempCode);
//比较密码
if TempName<>'' then
if Same=0 then
NoRegistry:=false;
//验证密码,通过NoRegistry为false
if NoRegistry then
begin //若未注册...
NumberOfDays:=Nowdate-FirstDate;
if((NumberOfDays>2) or (NumberOfDays<=-1)) then
begin
ShowMessage('程序未注册超过试用期或更改系统时间,将终止运行!');
Application.Terminate;//超过10天,则禁止运行
end else
begin
SpareDays:=Round(2-NumberOfDays);
ShowMessage('你已经剩下'+FloatToStr(SpareDays)+'天的使用时间了!请尽快注册!');
end;
end;
end;
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
if not timer1.Enabled then
begin
Timer1.Enabled:=true;
end;
end;
procedure TForm1.ToolButton2Click(Sender: TObject);
begin
if timer1.Enabled then
begin
Timer1.Enabled:=false;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
VAR
MSG:TMessage;
begin
if (VideoButton<>0) and (EndButton<>0) then
begin
if EndButtonVisible then
begin
SendMessage(EndButton,513,1,786491);
SendMessage(EndButton,514,0,786491);
EndButtonVisible:=False;
end else
begin
MSG.WParamHi:=VideoY;
MSG.WParamLo:=VideoX;
SendMessage(VideoButton,513,1,MSG.WParam);
SendMessage(VideoButton,514,0,MSG.WParam);
EndButtonVisible:=true;
end;
end;
end;
procedure TForm1.ToolButton5Click(Sender: TObject);
begin
with TForm2.Create(Application) do ShowModal;
end;
procedure TForm1.ToolButton3Click(Sender: TObject);
begin
tmr1.Enabled:=not tmr1.Enabled;
// ShellExecute(handle, nil,'帮助.mht', nil, nil,sw_shownormal);
end;
procedure TForm1.tmr1Timer(Sender: TObject);
begin
SetWindowPos(591960, HWND_BOTTOM, 0, 0, 0, 0, swp_nomove or swp_nosize and SWP_HIDEWINDOW);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -