For system tran icons:
The Taskbar -> Using the Taskbar
Or search these boards with "Shell_NotifyIcon".
Code:
#include <windows.h>
#include <iostream>
using namespace std;
HWND MyGetConsoleWindow()
{
// NOTE: if you have 2000/XP and latest Platform SDK, then you can simply
// call GetConsoleWindow()
char title[MAX_PATH];
if (GetConsoleTitleA(title, sizeof(title)))
{
return FindWindowA(NULL, title);
}//if
return 0;
}//MyGetConsoleWindow
bool HideConsoleWindow()
{
HWND hwnd;
if ((hwnd = MyGetConsoleWindow()) &&
ShowWindow(hwnd, SW_HIDE))
{
return true;
}//if
return false;
}//HideConsoleWindow
bool DisableSystemMenuClose()
{
HWND hwnd;
HMENU sysmenu;
if ((hwnd = MyGetConsoleWindow()) &&
(sysmenu = GetSystemMenu(hwnd, FALSE)) &&
DeleteMenu(sysmenu, SC_CLOSE, MF_BYCOMMAND))
{
return true;
}//if
return false;
}//DisableSystemMenuClose
int main()
{
if (!DisableSystemMenuClose())
{
cerr << "DisableSystemMenuClose() failed, ec = "
<< GetLastError() << endl;
return 1;
}//if
cout << "Just try and close me!" << endl;
Sleep(10 * 1000);
if (!HideConsoleWindow())
{
cerr << "HideConsoleWindow() failed, ec = "
<< GetLastError() << endl;
return 2;
}//if
MessageBoxA(NULL, "You can't see me!", "Ha-Ha", MB_OK);
return 0;
}//main
gg