guiThread.wait();
serverThread.wait();
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ){	appInstance = hInstance;	// Try to load riched20.dll	HMODULE hRiched = LoadLibrary( "riched20.dll" );	if( hRiched == 0 )	{		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 ) );	// Create the WindowClass	WNDCLASS wpClass;	ZeroMemory( &wpClass, sizeof( WNDCLASS ) );	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.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;		if( !RegisterClass( &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 );	cGuiThread guiThread( lpCmdLine );	guiThread.start( QThread::LowPriority );	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 );		}		TranslateMessage( &msg );		DispatchMessage( &msg );	}	keeprun = 0; // We quit, so let's quit the server too	guiThread.wait();		return guiThread.returnValue();}