Getting windows caption from process ID
I have a process ID, what I want to do is return the class. If it is the desi开发者_如何学运维red class then return the caption, how do I do that?
C Visual Studio 2008, XP SP3
Use EnumWindows with GetWindowThreadProcessID to find the HWND with the matching process ID that you're looking for.
Once you have the HWND you can use GetClassName to get the class name.
Once you have the HWND with the class you want you can use either:
- SendMessage to send a WM_GETTEXT.
- Or GetWindowText
Read Raymond Chen's post here on the differences.
精彩评论