• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Sending a message to a process

I like to send a message to a process main window.
I can get the process id with Process32First etc but then I'd like to send that process a message, for that I need the handle of the main window.
So my question is: How do I get a handle to the main window from the process id?

0
LucHoltkamp
Asked:
LucHoltkamp
1 Solution
 
WynCommented:
Try Thread32First() first and EnumThreadWindows()...

Regards
W.Yinan
0
 
MichaelSCommented:
If you know that process than you probably know the class of main window. If so you can use FindWindow() API.
0
 
LucHoltkampAuthor Commented:
Thanks for the reaction!
The problem with FindWindow is that MFC registrates the window class, and it's the same for all windows MFC creates....
So you can only select on Window title and that's not very reliable (the name changes in a SDI/MDI app).
Unfortunatly, it takes a lot of code to find the window, but it works and that is what counts...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now