?? unt_rundll.pas
字號:
unit unt_rundll;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,inifiles;
type
Tfrm_rundll = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
Function Reg:integer;
Function Reg_kill:integer;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_rundll: Tfrm_rundll;
implementation
{$R *.DFM}
procedure Tfrm_rundll.Button1Click(Sender: TObject);
begin
if reg=-1 then application.Terminate;
end;
Function Tfrm_rundll.Reg;
type
TFunc=function(A_sEditionFlag,A_allow_test,A_Email,A_URL,A_DISKKEY:pchar):pchar;
var
string1:string;
params:array[1..5]of string;
p,i:integer;
Menu_Table:string;
DllName:string;
DllParams:string;
filename,FuncName:string;
MenuCaption,str:string;
Func:Tfunc;
DllFunc:Thandle;
evnOK:boolean;
ret_value:string;
begin
DllName:='dllreg.dll';
if not(FileExists(extractfilepath(application.ExeName)+dllname)) then
begin
application.MessageBox('系統文件不完整,請重新安裝','系統安全檢查',48) ;
application.Terminate ;
end;
filename:=extractfilename(DllName);
FuncName:=copy(filename,4,pos('.',filename)-4);
string1:=DllParams;
for i:=1 to 5 do params[i]:='';
for i:=1 to 4 do begin
p:=pos('~',string1);
if p=0 then begin
params[i]:=trim(string1);
break;
end;
params[i]:=copy(string1,1,p-1);
string1:=copy(string1,p+1,length(string1)-p);
end;
params[1]:='TE10';//軟件名版本號 -只能是字符不能超過3位
params[2]:='10'; // 運行次數-只能是數字不能超過2位
params[3]:='tjsoft@51.net?Subject=注冊款已匯,申請注冊XX程序注冊號';
params[4]:='http://tjsoft.51.net';
params[5]:='True';
evnOk:=true;
if evnOK then begin
DllFunc:=Loadlibrary(pchar(DllName));
try
if DllFunc<>0 then begin
@Func:=GetProcAddress(DllFunc,pchar(FuncName));
if @Func<>nil then begin
//調用DLL函數
try
ret_value:=Func(pchar(params[1]),pchar(params[2]),pchar(params[3]),pchar(params[4]),pchar('TRUE'));//
if ret_value='DISKKEYTRUE' then
begin
result:=1;
// showmessage('磁盤正式版ok');
end;
if ret_value='REGTRUE' then
begin
result:=11;
// showmessage('注冊號正式版ok');
end;
if ret_value='TEST' then
begin
result:=111;
// G_Ver_test:=true;
// showmessage('注冊號試用版ok');
end;
if ret_value='-1' then
begin
result:=-1;
// showmessage('出錯啦');
end;
if (ret_value<>'DISKKEYTRUE') and (ret_value<>'REGTRUE') and
(ret_value<>'TEST')
then
begin
result:=strtoint(ret_value);
application.MessageBox(pchar('還能運行次數:'+ret_value),pchar(caption),48)
end;
except
raise;
end;
end;
end;
finally
Freelibrary(DllFunc);
end;
end;
end;
Function Tfrm_rundll.Reg_kill;
type
TFunc=function(A_sEditionFlag,A_allow_test,A_Email,A_URL,A_DISKKEY:pchar):pchar;
var
string1:string;
params:array[1..5]of string;
p,i:integer;
Menu_Table:string;
DllName:string;
DllParams:string;
filename,FuncName:string;
MenuCaption,str:string;
Func:Tfunc;
DllFunc:Thandle;
evnOK:boolean;
ret_value:string;
begin
DllName:='dllreg.dll';
if not(FileExists(extractfilepath(application.ExeName)+dllname)) then
begin
application.MessageBox('系統文件不完整,請重新安裝','系統安全檢查',48) ;
application.Terminate ;
end;
filename:=extractfilename(DllName);
FuncName:=copy(filename,4,pos('.',filename)-4);
string1:=DllParams;
for i:=1 to 5 do params[i]:='';
for i:=1 to 4 do begin
p:=pos('~',string1);
if p=0 then begin
params[i]:=trim(string1);
break;
end;
params[i]:=copy(string1,1,p-1);
string1:=copy(string1,p+1,length(string1)-p);
end;
params[1]:='TE10';//軟件名版本號 -只能是字符不能超過3位
params[2]:='-999'; // 表示刪除注冊
evnOk:=true;
if evnOK then begin
DllFunc:=Loadlibrary(pchar(DllName));
try
if DllFunc<>0 then begin
@Func:=GetProcAddress(DllFunc,pchar(FuncName));
if @Func<>nil then begin
//調用DLL函數
try
ret_value:=Func(pchar(params[1]),pchar(params[2]),pchar(params[3]),pchar(params[4]),pchar('TRUE'));//
except
raise;
end;
end;
end;
finally
Freelibrary(DllFunc);
end;
end;
end;
procedure Tfrm_rundll.Button2Click(Sender: TObject);
begin
reg_kill;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -