Click to See Complete Forum and Search --> : How to get the thread Handle for a Window?
Siva Prakash
March 23rd, 2004, 01:04 PM
Hi,
I am having a window handle. Using that can i get the handle of the thread that created that window?
Regards
Siva Prakash
RasKalnikov
March 23rd, 2004, 01:11 PM
You can use AfxGetThread()->m_nThreadID. You MUST make the call to AfxGetThread() from the thread whose ID you want.
kirants
March 23rd, 2004, 01:11 PM
GetWindowThreadProcessId
RasKalnikov
March 23rd, 2004, 01:12 PM
Learn something new every day!!!
kirants
March 23rd, 2004, 01:15 PM
Well, that one returns the thread and process IDs and not handles. Handles are not the same as IDs. Not sure what the user intends to do ...
Siva Prakash
March 23rd, 2004, 01:18 PM
Hi,
I am not using MFC in my application. And more over GetWindowThreadProcessId() function will return only the Thread ID and Process ID but I need to get the handle of the thread. I am having only the handle of the window. How to get the handle of the thread that created this window?
Regards
Siva Prakash
kirants
March 23rd, 2004, 01:24 PM
You could use OpenThread to get a thread handle, followed by CloseHandle to close the handle when you are done with the thread handle.
Siva Prakash
March 23rd, 2004, 03:30 PM
Hi,
I have to use my code in 98, me, nt, 2000, 2003 and XP. The API (openThread) you have specified is not supported in 98 and nt. Is there any other API that can be used for the same purpose.
Regards
Siva Prakash
kirants
March 23rd, 2004, 04:05 PM
Don't think there is a straightforward way. Anyways, amy I ask whats it that you are trying to acheive as the end result ?
wayside
March 23rd, 2004, 04:12 PM
Spy++ does it, so it should be possible.
Andreas Masur
March 23rd, 2004, 05:04 PM
[Moved thread]
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.