Console window creation

vterekh
vterekh used Ask the Experts™
on
Hi.

I want to know when a console window is created. I tried to set various hooks (CBT, SHELL) but them didn't work on console windows (Win2k, WinXP)

Is there any way to resolve this problem?
Vasily.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

How about hooking WH_SHELL. This should tell you when top level windows are created and destroyed.

when your dll is notified that a window is being created, There is a nCode value, which I think will give you the handle to the Window.

Another way you could do it, is to simply enumerate all top level windows using an windows enumeration proc and then get the caption of each window.

When it's one which has text like a console window, then
that's it.

hth,
J

Author

Commented:
Unfortunately, WH_SHELL doesn't work on console windows :(( (as i wrote). It's possible to use enum function, but i want dll to notify my application when console window is being created.
listening...
vterekh:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

From Microsoft MSDN:

It may be useful to manipulate a window associated with a console application. The Win32 API provides no direct method for obtaining the window handle associated with a console application. However, you can obtain the window handle by calling FindWindow(). This function retrieves a window handle based on a class name or window name.

Using Spy++  find the window and you will see the ClassName is
"ConsoleWindowClass"

You can use FindWindow("ConsoleWindowClass","") to find that window.

Hope that helps and my apologies for not following up on this sooner. I somehow missed it
I usually check on them, but missed this one.... until now.

hope this helps,
Sincerely,
J

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial