📄 unitsoftkeyclass.pas
字号:
unit UnitSoftKeyClass;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms,
Dialogs,IniFiles,CommClass,StdCtrls, ExtCtrls, ComCtrls, Registry;
//******************************************************************************
//**********************自定义函数很过程****************************************
function ReadProductId :String;
function ReadRegeditName:String;
function WomExecOutPro(const FileName: string; ExeType: Boolean): Boolean;
//******************************************************************************
var
Product_Id : String; //(操作系统)产品系列号
RegeditName : String; //注册用户名
//****************************************************************************//
implementation
uses UnitMain, UnitkeyCryptClass;
function WomExecOutPro(const FileName: string; ExeType: Boolean): Boolean; //执行外部程序。ExeType:是否等待执行结束,True为一直等待
var
sInfo: TStartupInfo;
pInfo: TProcessInformation;
TmpDWORD: DWORD;
begin
FillChar(sInfo, sizeof(sInfo), #0);
sInfo.cb := SizeOf(sInfo);
sInfo.dwFlags := STARTF_USESHOWWINDOW;
sInfo.wShowWindow := SW_NORMAL;
try
CreateProcess(nil, PChar(FileName), nil, nil, False, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, sInfo, pInfo);
if ExeType = False then
Result := True
else
begin
waitforsingleobject(pInfo.hProcess, INFINITE);
GetExitCodeProcess(pInfo.hProcess, TmpDWORD);
CloseHandle(pInfo.hProcess);
CloseHandle(pInfo.hThread);
Result := True;
end;
except
Result := False;
Exit;
end;
end;
//读注册表中系统产品序列号
function ReadProductId:String;
var
Reg:TRegistry;
begin
try
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey('Software\Microsoft\Windows NT\CurrentVersion',False);
Result:=Reg.ReadString('ProductId');
except
Application.MessageBox('读系统注册表失败!!','系统错误',MB_ICONERROR+MB_OK);
end;
end;
//读注册表的信息并校验是否一致
function ReadRegeditName:String;
var
re_id : integer;
Soft_UserName : String;
RegeditID : String;
RegisterName : TRegistry;
RegisterUID : TRegistry;
inputstr,get_id : string;
dy,clickedok : boolean;
Myini : TiniFile;
IniNameStr : String;
AuthName : String;
IniUIDStr : String;
begin
//************************************************************************//
//从注册表读产品序列号
RegisterUID := TRegistry.Create; //准备使用注册表
RegisterUID.RootKey:=HKEY_LOCAL_MACHINE; //存放在此根下
// 建一目录,存放标志值。
RegisterUID.OpenKey('Software\Microsoft\Windows NT\CurrentVersion',False);
RegeditID:=RegisterUID.ReadString('ProductId');
RegisterUID.CloseKey;
RegisterUID.Free;
//从系统文件中读加密后的序列号
Myini:=TIniFile.Create(ExtractFileDir(application.Exename)+'\SystemSet.ini');
IniUIDStr:=Myini.ReadString('SoftWareSet','Product_Id','');
Myini.Free;
if Trim(IniUIDStr)='' then
begin
Application.MessageBox('系统未进行【注册】!请注册!注册后才能够正常使用!',Pchar(Application.Title),MB_ICONERROR+MB_OK);
WomExecOutPro(ExtractFilePath(Application.ExeName) + 'GD_SoftRegedit.exe', True);
Application.Terminate;
end
else
begin
IniUIDStr:=Encrypt(IniUIDStr,'luersoft');
if Trim(IniUIDStr)<>Trim(RegeditID) then
begin
Application.MessageBox('进行的是非法【注册】!正确注册后才能够正常使用!',Pchar(Application.Title),MB_ICONERROR+MB_OK);
WomExecOutPro(ExtractFilePath(Application.ExeName) + 'GD_SoftRegedit.exe', True);
Application.Terminate;
end
else
begin
RegisterName := TRegistry.Create; //准备使用注册表
RegisterName.RootKey:=HKEY_LOCAL_MACHINE; //存放在此根下
// 建一目录,存放标志值。
RegisterName.OpenKey('Software\Microsoft\Windows\CurrentVersion\LuerSoft',True);
if RegisterName.ValueExists('Regedit_UserName') then //用Regedit_UserName的值作为标志,首先判断其存在否?
begin
Soft_UserName:=RegisterName.ReadString('Regedit_UserName');//读出标志值
Myini:=TIniFile.Create(ExtractFileDir(application.Exename)+'\SystemSet.ini');
IniNameStr:=Myini.ReadString('SoftWareSet','RegeditName','');
IniNameStr:=Encrypt(IniNameStr,'luersoft');
AuthName:=Copy(IniNameStr,Length(IniNameStr)-3+1,3);
if AuthName<>'zzh' then
begin
Application.MessageBox('进行的是非法【注册】!正确注册后才能够正常使用!',Pchar(Application.Title),MB_ICONERROR+MB_OK);
WomExecOutPro(ExtractFilePath(Application.ExeName) + 'GD_SoftRegedit.exe', True);
Application.Terminate;
end
else
begin
IniNameStr:=Copy(IniNameStr,1,Length(IniNameStr)-3);
if Trim(IniNameStr)<>Trim(Soft_UserName) then
begin
Application.MessageBox('进行的是非法【注册】!正确注册后才能够正常使用!',Pchar(Application.Title),MB_ICONERROR+MB_OK);
WomExecOutPro(ExtractFilePath(Application.ExeName) + 'GD_SoftRegedit.exe', True);
Application.Terminate;
end;
end;
end
else
begin
Application.MessageBox('系统未进行【注册】!请注册!注册后才能够正常使用!',Pchar(Application.Title),MB_ICONERROR+MB_OK);
WomExecOutPro(ExtractFilePath(Application.ExeName) + 'GD_SoftRegedit.exe', True);
Application.Terminate;
end;
RegisterName.CloseKey;
RegisterName.Free;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -