![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
SetWindowsHookEx [D5, Win95/98]
YUS © (2001-11-18 19:07:00)Мастера,подскажите почему функция 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;
YUS (2001-11-19 07:26:00) [1]Всем Спасибо HookID:=SetWindowsHookEx(WH_GETMESSAGE, @GetMsdProc,hinstance,ThreadID);
YUS (2001-11-19 07:02:00) [2]Хук устанавливается, но обращения к GetMsgProc функции нет.
paul_shmakov (2001-11-19 00:21:00) [3]
ThreadID := GetWindowThreadProcessId(hStol,@IDProc);
HookID:=SetWindowsHookEx(WH_GETMESSAGE, @GetMsdProc,0,ThreadID);
YUS (2001-11-18 22:51:00) [4]Нет, ничего не выходит.Возвращает 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;
YUS (2001-11-18 20:48:00) [5]СПАСИБО за ПОМОЩЬ!!!!!!!!
Polevi (2001-11-18 19:51:00) [6]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 19:28:00) [7]Прошу прошения --потока. Его нахожу функцией, GetWindowThreadProcessId(hwnd,@IDProc);где hwnd- хэндл окна.
paul_shmakov (2001-11-18 19:13:00) [8]потому как последний параметр функции SetWindowsHookEx не идентификатор процесса, а идентификатор потока.