I would like to add a hook to an application. I am using SetWindowsHookEx
and I can create a system wide hook, but I want to create a hook for a particular application. I need to have thread id of the target application to hook it. I know title of the window, I know exe name and from these I can get window handle and process id, but how do I get the thread id? I saw a post about how to do it in c#, but I do not see how to get a list of threads in c++.
HWND windowHandle = FindWindow(NULL, _T("SomeOtherApp"));
DWORD processId = GetWindowThreadProcessId(windowHandle, NULL);
DWORD threadId = ??? // How do I get thread id here?
HHOOK hook = ::SetWindowsHookEx( WH_CBT, HookCBTProc, hInst, threadId);
Thanks, Alexander.