<p>I have a written a Visual C++ console application (i.e. subsystem:console) that prints useful diagnositic messages to the console.</p>

<p>However, I would like to keep the application minimized most of the time, and instead of minimizing to the taskbar, appear as a nice icon on the system tray. I would also like to restore the console when the system tray icon is clicked.</p>

<p>How should I change my program to do this?</p>

This is going to be an ugly hack.
First, you have to retrieve the
```
hWnd
```
/
```
hInstance
```
of you console application. Right now, I can only come up with one way:
Create a Guid with
```
CoCreateGuid()
```
Convert it to a string
Set the title of the console window to this guid with
```
SetConsoleTitle()
```
Find the
```
hWnd
```
of the your window with the Guid as the tile with
```
FindWindow()
```
And you can do it from the usual way from this point.
See http://www.gidforums.com/t-9218.html for more info.
Don't forget the rename your console window to the original title once you're done.
As you can see, even though this is possible to do, it's a horrible and painful solution. Please don't do it. Please do not minimize console applications to the system tray.
It is not something you are supposed to be able to do in the Windows API.