Вниз
Скачать: CL | DM;

SetWindowsHookEx   Найти похожие ветки 

← →
YUS   (2001-11-18 19:07) [0]

Мастера,подскажите почему функция SetHook возвращает false при (IDProc=ID процесса куда устанавливаем хук), но если
SetWindowsHookEx(WH_GETMESSAGE,@GetMsdProc,hInstance,0); ,то true. Почему хук не устанавливается в заданный процесс???

function SetHook(IDProc:Cardinal):boolean; export;
begin
HookID:=SetWindowsHookExWH_GETMESSAGE,@GetMsdProc,
hInstance,IDProc);
if HookID = 0 then Result:=false else Result:=true;


← →
paul_shmakov ©   (2001-11-18 19:13) [1]

потому как последний параметр функции SetWindowsHookEx не идентификатор процесса, а идентификатор потока.


← →
YUS   (2001-11-18 19:28) [2]

Прошу прошения --потока. Его нахожу функцией, GetWindowThreadProcessId(hwnd,@IDProc);где hwnd- хэндл окна.


← →
Polevi ©   (2001-11-18 19:51) [3]

hMod

Identifies the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.

dwThreadId

Specifies the identifier of the thread with which the hook procedure is to be associated. If this parameter is zero, the hook procedure is associated with all existing threads.


HookID:=SetWindowsHookEx(WH_GETMESSAGE,@GetMsdProc,
0,IDProc);


← →
YUS   (2001-11-18 20:48) [4]

СПАСИБО за ПОМОЩЬ!!!!!!!!


← →
YUS   (2001-11-18 22:51) [5]

Нет, ничего не выходит.Возвращает false. Привожу полное описание функции.

function SetHook(hMain:THandle):boolean; export;
var
IDProc : cardinal;
begin
hServ:=hMain;
GetWindowThreadProcessId(hStol,@IDProc); //находим его ID
HookID:=SetWindowsHookEx(WH_GETMESSAGE, @GetMsdProc,0,IDProc);
if HookID <> 0 then begin
PostThreadMessage(IDProc,WM_NULL,0,0);
Result:=true;
end else Result:=false;
end;



← →
paul_shmakov ©   (2001-11-19 00:21) [6]


ThreadID := GetWindowThreadProcessId(hStol,@IDProc);
HookID:=SetWindowsHookEx(WH_GETMESSAGE, @GetMsdProc,0,ThreadID);


← →
YUS   (2001-11-19 07:02) [7]

Хук устанавливается, но обращения к GetMsgProc функции нет.


← →
YUS   (2001-11-19 07:26) [8]

Всем Спасибо HookID:=SetWindowsHookEx(WH_GETMESSAGE, @GetMsdProc,hinstance,ThreadID);



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.006 c
1-66249
wicked
2002-01-02 11:49
2002.01.21
Вопросец по LISTVIEW


4-66391
Floyn
2001-11-20 10:00
2002.01.21
Как в DLL создать окно?


1-66226
ctapik-net
2002-01-02 01:11
2002.01.21
Загрузка изображения из RES-файла


1-66238
~(;_;)~
2001-12-28 14:48
2002.01.21
Как сделать какой-то файл, скажем – «C: Test.cnf» заблокированным?!


7-66378
SERG_NENIA
2001-09-28 08:15
2002.01.21
как быть с организацие поиска




   Наверх