Shell_NotifyIcon(NIM_DELETE, &icondata);
Shell_NotifyIconA(NIM_DELETE, (PNOTIFYICONDATAA)&icondata);
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ){	INITCOMMONCONTROLSEX initex;	initex.dwICC = ICC_WIN95_CLASSES;	initex.dwSize = sizeof(INITCOMMONCONTROLSEX);	InitCommonControlsEx(&initex);	appInstance = hInstance;	guiThread = GetCurrentThreadId();	// Try to load riched20.dll	HMODULE hRiched = LoadLibrary("riched20.dll");	if (!hRiched)	{		MessageBox( 0, "The riched20.dll library could not be found on your system.\nPlease install Microsoft Internet Explorer 4.0 or later.", "Missing DLL", MB_OK|MB_ICONERROR );		return 1;	}	hbSeparator = CreateSolidBrush( RGB( 0xAF, 0xAF, 0xAF ) );	hbBackground = CreateSolidBrush( RGB( 0, 64, 38 ) );	iconGreen = (HICON)LoadImage(appInstance, MAKEINTRESOURCE(IDI_ICONGREEN), IMAGE_ICON, 16, 16, 0);	iconRed = (HICON)LoadImage(appInstance, MAKEINTRESOURCE(IDI_ICONRED), IMAGE_ICON, 16, 16, 0);	// Create the WindowClass	WNDCLASSEX wpClass;	ZeroMemory( &wpClass, sizeof( WNDCLASSEX ) );	wpClass.cbSize = sizeof(WNDCLASSEX);	wpClass.hInstance = hInstance;	wpClass.lpfnWndProc = wpWindowProc;	wpClass.hCursor = LoadCursor( NULL, MAKEINTRESOURCE( IDC_ARROW ) );	wpClass.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_ICON1 ) );	wpClass.hbrBackground = hbBackground;	wpClass.lpszClassName = WOLFPACK_CLASS;	wpClass.hIconSm = iconRed;	wpClass.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;		if (!RegisterClassEx(&wpClass))	{		MessageBox(0, "Couldn't register Window Class.", "Window Class", MB_OK|MB_ICONERROR);		return 1;	}	// Create the Window itself	hmMainMenu = LoadMenu( appInstance, MAKEINTRESOURCE( IDR_MAINMENU ) );	mainWindow = CreateWindow( WOLFPACK_CLASS, "Wolfpack", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, hmMainMenu, hInstance, NULL );	if( mainWindow == 0 )	{		MessageBox( 0, QString( "Couldn't create the window: " + getErrorString() ).latin1(), "Wolfpack", MB_OK|MB_ICONERROR );		return 1;	}	ShowWindow( mainWindow, SW_NORMAL );	// Create the System Tray Icon	ZeroMemory(&icondata, sizeof(icondata));	icondata.cbSize = sizeof(icondata);	icondata.hWnd = mainWindow;	icondata.uID = 0;	icondata.uFlags = NIF_MESSAGE|NIF_ICON;	icondata.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));	icondata.uCallbackMessage = WM_TRAY_NOTIFY;	// This is "ported" from MFC	tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP|TTS_NOPREFIX|TTS_ALWAYSTIP|TTS_BALLOON,		CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, mainWindow, NULL, hInstance, NULL);		if (tooltip) {		TOOLINFO info;		info.cbSize = sizeof(info);		info.uFlags = TTF_TRANSPARENT|TTF_CENTERTIP;		info.hwnd = mainWindow;		info.uId = 0;		info.hinst = 0;		info.lpszText = LPSTR_TEXTCALLBACK;		GetClientRect(mainWindow, &info.rect);		SendMessage(tooltip, TTM_ADDTOOL, 0, (LPARAM)&info);	}	Shell_NotifyIcon(NIM_ADD, &icondata);	cServerThread serverThread(lpCmdLine);	serverThread.start();	MSG msg;	while( GetMessage( &msg, 0, 0, 0 ) > 0 )	{		if( msg.message == WM_CHAR && msg.hwnd == inputWindow && msg.wParam == '\r' )		{			if( serverState == RUNNING )			{				char command[512] = { 0, };				GetWindowText( inputWindow, command, 512 );				SetWindowText( inputWindow, "" );      				// We are in a different Thread. Remember that.				Console::instance()->queueCommand( command );			}			continue;		}		else if( msg.message == WM_TIMER )		{			char message[512];			unsigned int msecs, seconds, minutes, hours, days;			days = uiCurrentTime / 86400000;			hours = (uiCurrentTime % 86400000) / 3600000;			minutes = (( uiCurrentTime % 86400000 ) % 3600000 ) / 60000;			seconds = ((( uiCurrentTime % 86400000 ) % 3600000 ) % 60000 ) / 1000;			sprintf( message, "Uptime: %u:%02u:%02u:%02u", days, hours, minutes, seconds );			SetWindowText( lblUptime, message );			// Update the icon			static unsigned int lastState = 0xFFFFFFFF;			if (lastState != serverState) {				if (serverState == RUNNING) {					SendMessage(mainWindow, WM_SETICON, ICON_SMALL, (WPARAM)iconGreen);					SendMessage(statusIcon, STM_SETIMAGE, IMAGE_ICON, (LPARAM)iconGreen);				} else {					SendMessage(mainWindow, WM_SETICON, ICON_SMALL, (WPARAM)iconRed);					SendMessage(statusIcon, STM_SETIMAGE, IMAGE_ICON, (LPARAM)iconRed);				}			}			lastState = serverState;		}		TranslateMessage( &msg );		DispatchMessage( &msg );	}	Shell_NotifyIcon(NIM_DELETE, &icondata);	keeprun = 0; // We quit, so let's quit the server too	serverThread.wait();		return serverThread.returnValue();}