Official workarounds: handle to console window

Say that you have a console application and you want to get a handle to your console window. If your process was the one to create the console window then you're lucky, as you can use EnumWindows to find it. But what if your process is a child process borrowing the console window from another process? Don't worry, Microsoft has the answer:

Basically it's this: temporarily change title of console window to something unique – then wait some time to ensure that the title has changed, and then search for a window with that title. Thank you Microsoft, that seems completely sane and not the least bit fragile in any way…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.