📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AAFont, AACtrls, jpeg, ExtCtrls, LbSpeedButton,Registry ;
type
TForm2 = class(TForm)
Image1: TImage;
Image2: TImage;
AALabel9: TAALabel;
AALabel2: TAALabel;
AALabel1: TAALabel;
AALabel3: TAALabel;
LbSpeedButton5: TLbSpeedButton;
LbSpeedButton6: TLbSpeedButton;
LbSpeedButton8: TLbSpeedButton;
AALabel4: TAALabel;
procedure LbSpeedButton5Click(Sender: TObject);
procedure LbSpeedButton6Click(Sender: TObject);
procedure LbSpeedButton8Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function CreateMutex: Boolean; // 全项目公用函数
procedure DestroyMutex; // 全项目公用函数
var
Form2: TForm2;
REG:TRegistry;
Mutex: hWnd;
implementation
uses mainunit, REGUnit,SoftReg;
{$R *.dfm}
procedure DestroyMutex;
begin
if Mutex <> 0 then CloseHandle(Mutex);
end;
function CreateMutex: Boolean;
var
PrevInstHandle: THandle;
AppTitle: PChar;
begin
AppTitle := StrAlloc(100);
StrPCopy(AppTitle, Application.Title);
Result := True;
Mutex := Windows.CreateMutex(nil, False, AppTitle);
if (GetLastError = ERROR_ALREADY_EXISTS) or (Mutex = 0) then begin
Result := False;
SetWindowText(Application.Handle, '');
PrevInstHandle := FindWindow(nil, AppTitle);
if PrevInstHandle <> 0 then begin
if IsIconic(PrevInstHandle) then
ShowWindow(PrevInstHandle, SW_RESTORE)
else
BringWindowToTop(PrevInstHandle);
SetForegroundWindow(PrevInstHandle);
end;
if Mutex <> 0 then Mutex := 0;
end;
StrDispose(AppTitle);
end;
procedure TForm2.LbSpeedButton5Click(Sender: TObject);
begin
if Application.MessageBox('是否真的退出“商品房买卖合同套打程序”?','询问'
,MB_YESNO+MB_ICONQUESTION )=IDYES then
Application.Terminate ;
end;
procedure TForm2.LbSpeedButton6Click(Sender: TObject);
begin
Form1:=TForm1.Create(self);
form1.ShowModal ;
end;
procedure TForm2.LbSpeedButton8Click(Sender: TObject);
begin
If Assigned(RegSoftForm) Then Begin
SetWindowPos(RegSoftForm.Handle, 0, 0, 0, 0, 0, swp_nomove +
swp_nosize);
Exit;
End;
RegSoftForm := TRegSoftForm.create(self);
RegSoftForm.ShowModal;
end;
procedure TForm2.FormCreate(Sender: TObject);
var
nows,firstruns:TDate;
bFirst:Boolean ;
sMcode,sNo,SReg:string;
begin
nows:=Date;
REG:=TRegistry.Create ;
REG.RootKey := HKEY_LOCAL_MACHINE;
bfirst:=not reg.KeyExists('SOFTWARE\ABICO\HTPrinter');
if bfirst then BEGIN
Application.MessageBox('你是第一次运行这个程序!你暂时只能使用5天!'+#13+
'如要继续使用请与安邦公司联系取得注册码并进行注册!',
'提示',MB_OK+MB_ICONINFORMATION );
END;
REG.OpenKey('SOFTWARE\ABICO\HTPrinter', true);
if bfirst then
REG.WriteBinaryData('FirstRun',nows,SizeOf(nows));
reg.WriteBinaryData('Now',nows,SizeOf(nows));
REG.ReadBinaryData('now',nows,SizeOf(nows));
REG.ReadBinaryData('firstrun',firstruns ,SizeOf(firstruns ));
if (nows-firstruns>5)OR(nows-firstruns<0) then begin
IF REG.ValueExists('KEY_ID') then begin
sMcode :=REGUnit.GetMachineCode ;
SNO:=REGUnit.GetSNFromMCode(SMCODE);
SREG:= REG.ReadString('KEY_ID');
// ShowMessage('SNO='+sNo+#13+'SREG='+SReg);
if sNo=SREG theN BEGIN
LbSpeedButton6.Visible :=TRUE;
LbSpeedButton8.Visible :=FALSE;
REG.FREE;
Exit;
end;
END;{ ELSE begin
Application.MessageBox('软件已超出使用期限且未注册!'+#13+
'如要继续使用请与安邦公司联系取得注册码并进行注册!',
'警告',MB_OK+MB_ICONERROR );
LbSpeedButton6.Visible :=False;
LbSpeedButton8.Visible :=TRUE;
REG.FREE;
Exit;
END; }
Application.MessageBox('软件已超出使用期限!'+#13+
'如要继续使用请与安邦公司联系取得注册码并进行注册!',
'警告',MB_OK+MB_ICONERROR );
LbSpeedButton6.Visible :=False;
LbSpeedButton8.Visible :=TRUE;
end ELSE begin
LbSpeedButton6.Visible :=TRUE;
LbSpeedButton8.Visible :=TRUE;
END;
REG.FREE;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -