📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Registry, Buttons, ExtCtrls,Sockets;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Image1: TImage;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
function Pass(pstr:string):string;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var RunResult:integer;
begin
{ RunResult:=WinExec(PChar('\HaiNan\Pt_Drv.exe'),Sw_Hide);
If RunResult<31 then Begin
messagebox(application.handle,'连接工作数据库失败:ORA-12560:TNS:协议识配器错误','错误信息',mb_ok+mb_iconinformation);
Application.Terminate;
End; }
edit2.Text:=pass(edit1.Text);
end;
function Tform1.pass(pstr:string):string;
var str,str1:string;
i,j:integer;
begin
str:=pstr;
for i:=1 to length(str) do begin
//进行第一次变换
//j:=(i*i*i mod (i+20))+(i*i mod (i+10))+i*2+1;
j:=(i*i*i mod (i+10))+(i*i mod (i+20))+i*2+1;
str1:=str1+chr(ord(str[i])+j); //第二次变换
//j:=(i*i*i mod (i+10))+(i*i mod (i+20))+i*2+1;
j:=(i*i*i mod (i+20))+(i*i mod (i+10))+i*2+1;
str1:=str1+chr(ord(str[i])+j);
end;
pass:=str1;
end;
procedure TForm1.FormCreate(Sender: TObject);
var RunResult:integer;
Ss:HWnd;
Reg,reg1: TRegistry;
Myreg:String;
MySeri,s,s1:String;
i:integer;
tp:ttcpclient;
strname,straddr:string;
Myseri2:String;
begin
tp:=ttcpclient.create(self);
tp.close;
tp.open;
strname:=tp.LocalHostName;
straddr:=tp.LocalHostAddr;
label1.caption:=strname+' IP: '+straddr;
// myip:=straddr;
tp.close;
try
Reg:= TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('software',True) then begin
reg.WriteString('L.Z.Soft.Ver','Window2000');
if reg.ReadString('UserID')='' Then begin
reg.WriteString('UserID','');
end;
//-------------------------------------------系统未注册
if reg.readstring('UserID')='' Then begin
Application.MessageBox(pchar('系统未注册!'),'注册信息',mb_iconwarning);
MySeri:=formatdatetime('ssmmssnnhhdd',now);
s1:='';
for i:=1 to 12 do begin
s:=copy(MySeri,i,1);
s:=inttostr(strtoint(s)+i);
if length(S)=1 then s:=s;
if length(s)=2 then s:=copy(s,2,1);
s1:=S1+s;
end;
reg.WriteString('UserID',Trim(s1)+'★'+strname);
Close;
end;
//----------------------------------------------- //系统未注册--系统已注册
//------------------------------------------------------
if reg.readstring('UserID')<>'' Then begin
edit1.Text:=copy(reg.readString('UserID'),1,pos('★',reg.readString('UserID'))-1);
Myseri2:=reg.readString('UserID');
reg.CloseKey;
if Reg.OpenKey('Control Panel',True) then begin
// showmessage(Reg.ReadString('User'));
if Reg.ReadString('User')+'★'+strname<>Myseri2 Then begin
Application.MessageBox(pchar('系统未注册!'),'注册信息',mb_iconwarning);
edit2.Text:='';
exit;
end;
end
end
end
finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
//******
ss:=FindWindow('Tform1','驾驶人理论考试系统( 培训版)');
if ss=0 then begin
RunResult:=WinExec(PChar('c:\project2.exe /?'),Sw_Show);
If RunResult<31 then
messagebox(application.handle,'','错误信息',mb_ok+mb_iconinformation);
Application.Terminate;
End;
if ss<>0 Then begin
messagebox(application.handle,'程序正在运行!','系统信息',mb_ok+mb_iconinformation);
Application.Terminate;
end;
close;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var RunResult:integer;
Ss:HWnd;
Reg,reg1: TRegistry;
Myreg:String;
MySerio,s,s1:String;
i:integer;
begin
try
Reg:= TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('software',True) then begin
if reg.readstring('UserID')<>'' Then begin
// MySerio:=reg.readString('UserID');
MySerio:=copy(reg.readString('UserID'),1,pos('★',reg.readString('UserID'))-1);
if Trim(edit2.Text)<>pass(Myserio) Then begin
Application.MessageBox(pchar('系统注册错误!'),'注册信息',mb_iconwarning);
edit2.Text:='';
exit;
end;
Reg.CloseKey;
if Trim(edit2.Text)=pass(Myserio) Then begin
if Reg.OpenKey('Control Panel',True) then begin
// if reg.readstring('User')='' Then begin
Reg.WriteString('User',Trim(edit1.Text));
Application.MessageBox(pchar('感谢您使用本系统!请重新启动程序'),'注册信息',mb_iconwarning);
edit2.Text:='';
//exit;
// end;
Close;
end;
end
end;
end;
finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -