procedure RunStopHook(b:boolean);stdcall;external ‘hdll.dll’; // проца в нашей DLL’ке с хуком.
begin
RunStopHook(true);
h := FindWindowEx(0, 0, ‘Shell_TrayWnd’, nil);
h := FindWindowEx(h, 0, ‘TrayNotifyWnd’, nil);
h := FindWindowEx(h, 0, ‘TrayClockWClass’, nil);
sleep(1000); // что бы наша Dll’ка успела загрузиться.
postmessage(h,wm_paint,0,0);
zeromemory(@FI,sizeof(FI));
FI.cbSize:=sizeof(FI);
FI.szTip:=’Hello temp’;
FI.uFlags:=NIF_TIP;
FI.Wnd:=GetDeskTopWindow;
Shell_NotifyIcon(NIM_ADD,@FI); // у часов мы в дальнейшем поменяем отрисовку (для наглядности)
Shell_NotifyIcon(NIM_DELETE,@FI);
end.
Так-с. Теперь подумаем о реализации ДЛЛки с хуком. Процедура перехвата должна сверять хэндл часов с хэндлом перехватываемого message’а. Если они равны, то ДЛЛка в процессе Explorer’а. И тут мы уже можем менять процедуру окна часов. Но всё по порядку :).
library hdll;
uses
SysUtils,
Classes,
windows,
messages;
{$R *.res}
var syshook:hhook; // переменная для хука
procedure GetAndSet(h:integer);stdcall; external ‘gas.dll’; // процедура из 2-ой ДЛЛки, которая заменит оконную процедуру часов.
function CallWndProc(
nCode:integer ; // hook code
wParam: WPARAM ; // current-process flag
lParam: LPARAM // address of structure with message data
):LRESULT;stdcall;
var h:integer;
ok:boolean; // переменная влияющая на снятие хука. (т.е. показывающая, что оконная процедура часов изменена)
begin
ok:=false;
H := FindWindowEx(0, 0, ‘Shell_TrayWnd’, nil);
H := FindWindowEx(H, 0, ‘TrayNotifyWnd’, nil); // все пэрэнты часов можно узнать с помощью Spy++ (а любителей кодинга отсылаю к MSDN GetParent & WindowFromPoint)
if tmsg(pointer(lparam)^).hwnd=H then begin
h := FindWindowEx(H, 0, ‘TrayClockWClass’, nil); // получаем хэндл часов
loadlibrary(‘gas.dll’); // загружаем 2-ую ДЛЛку (чтобы она висела в процессе Explorer’а)
GetAndSet(h); // меняем ему процедуру
Invalidaterect(h,nil,false); //sendmessage(h,wm_paint,0,0);
ok:=true;
end;
result:=CallNextHookex(syshook,ncode,wparam,lparam);
if ok then UnHookWindowsHookEx(syshook); // отключаем хук
end;
procedure RunStopHook(b:boolean);export;stdcall;
begin
Обсуждене
Отзывов нет на «Invisible Soft»
Ваш отзыв