看看我写的代码,也许对你有帮助
dll程序:
library MeteorHook;
uses
Windows,Messages,Dialogs;
var
MouseHook:HHook;
procedure FindMeteorWindow;
var
window:Longint;
buffer:array[0..50] of char;
startWindow:Longint;
begin
window:=GetForeGroundWindow;
GetClassName(window,buffer,10);
if buffer<>'#32770' then exit;
if FindWindowEx(window,0,'Button','储存帐号密码')=0 then exit;
if FindWindowEx(window,0,'Button','开始游戏')=0 then exit;
ShowMessage('流星蝴蝶剑正在维护中,请稍候再玩');
SendMessage(window,WM_CLOSE,0,0);
end;
function HookMouse(iCode: Integer; wParam: WPARAM;
lParam: LPARAM): LRESULT; stdcall; export;
begin
if wparam=WM_LBUTTONDOWN then FindMeteorWindow;
Result := CallNextHookEx(MouseHook, iCode, wParam, lParam);
end;
procedure HookOn;
begin
MouseHook:=SetWindowsHookEx(WH_mouse, HookMouse, HInstance, 0);
end;
procedure HookOff;
begin
UnHookWindowsHookEx(MouseHook);
end;
exports
HookOn,
HookOff;
begin
end.
主程序
program Main;
uses
Windows,Messages,Dialogs;
var Msg : TMsg;
procedure HookOn ; stdcall; external 'MeteorHook.dll';
procedure HookOff ; stdcall; external 'MeteorHook.dll';
begin
HookOn;
while GetMessage(Msg, 0, 0, 0) do ;
HookOff;
end.