delphi - WH_SHELL Hook do not recognize other processes' messages on Windows 8 -
i'm trying notice, when onenote opened or set foreground. searched old source files , found dlls hooks, did job on win xp. awefully, not on windows 8. messages own application including buttons , textfields, no other application triggers callback function :-( running hook-starting exe administrator, doesn't change issue.
var hookhandle: cardinal = 0; windowhandle : cardinal = 0; function hookproc(ncode: integer; wparam: wparam; lparam: lparam): lresult; stdcall; var s:pchar; begin result := callnexthookex(hookhandle, ncode, wparam, lparam); // debug if callback function triggerd... sendmessage(windowhandle,wm_user+999,wparam,lparam); case ncode < 0 of true: exit; false: begin if ncode=hshell_windowcreated begin sendmessage(windowhandle,wm_user+999,wparam,lparam); getmem(s,getwindowtextlength(wparam)+2); getwindowtext(wparam,s,getwindowtextlength(wparam)+2); //if (ansiendsstr('onenote',s)) begin callnexthookex(hookhandle, ncode, wparam, lparam); end; end; end; end; function installhook(hwnd: cardinal): boolean; stdcall; begin result := false; if hookhandle = 0 begin hookhandle := setwindowshookex(wh_shell, @hookproc, hinstance, 0); windowhandle := hwnd; result := true; end; end; function uninstallhook: boolean; stdcall; begin result := unhookwindowshookex(hookhandle); hookhandle := 0; end; exports installhook, uninstallhook; end.
Comments
Post a Comment