ok this code compiles fine but when i run this window I get an error from windows Im not sure why
using msvc++ 6.0 + windows xp

Code:
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//////////////////
//
//
// Title: DrawingStuff
// Author: Brad Hoffer
// Notes: Good luck to myself!
//
//
//////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////


#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <stdlib.h>


int GameInit();
	int GameLoop();
	int GameShutdown();
	
	HWND g_hWndMain;






long CALLBACK WndProc( HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam )

{
	PAINTSTRUCT PaintStruct;
	
	HDC hDC;
	
	
	
	switch (uMessage)
	{
		case WM_CREATE:
			{
				return 0;
			}

		case WM_PAINT:
			{

				hDC = BeginPaint(hWnd, &PaintStruct);
				
				EndPaint (hWnd, &PaintStruct);

				return 0;
			}

		case WM_DESTROY:
			{
				PostQuitMessage(0);
				
				return 0;
			}

		default:
			{
				return DefWindowProc(hWnd, uMessage, wParam, lParam);
			}
	}
}



int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pstrCmdLine, int iCmdShow)

	{
		HWND hWnd;
		MSG msg;
		WNDCLASSEX wc;
		
		

		static char strAppName[] = "Brads first win app";

		
		
		
		
		wc.cbSize = sizeof(WNDCLASSEX);
		wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
		wc.cbClsExtra = 0;
		wc.cbWndExtra = 0;
		wc.lpfnWndProc = WndProc;
		wc.hInstance = hInstance;
		wc.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
		wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
		wc.hIconSm = LoadIcon(NULL, IDI_HAND);
		wc.hCursor = LoadCursor(NULL, IDC_CROSS);
		wc.lpszMenuName = NULL;
		wc.lpszClassName = strAppName;

		RegisterClassEx(&wc);

		hWnd = CreateWindowEx( NULL,
								strAppName,
								strAppName,
								WS_OVERLAPPEDWINDOW,
								CW_USEDEFAULT,
								CW_USEDEFAULT,
								512,512,
								NULL,
								NULL,
								hInstance,
								NULL);
		g_hWndMain = hWnd;

		GameInit();

		ShowWindow(hWnd, iCmdShow);

		UpdateWindow(hWnd);


		while(TRUE)
		{
			
			if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
				{
					if (msg.message == WM_QUIT)
						break;

					TranslateMessage(&msg);

					DispatchMessage(&msg);
				}

			else
				{

				GameLoop();
				
				}
		}
		
		GameShutdown();
		return msg.wParam;
}


int GameInit()
{
	return 0;
}


int GameLoop()
{
	HDC hDC;

	hDC = GetDC(g_hWndMain);
	
	RECT ClientRect;
	
	GetClientRect(g_hWndMain,&ClientRect);

	if (ClientRect.bottom == 0 || ClientRect.right == 0)
		{
			ReleaseDC(g_hWndMain,hDC);
			return 0;
		}

	HPEN hPen = CreatePen(PS_SOLID,rand()%5,RGB(rand()%255,rand()%255,rand()%255,));

	LOGBRUSH logBrush;

	logBrush.lbColor = RGB(rand()%255,rand()%255,rand()%255);
	logBrush.lbHatch = 0;
	logBrush.lbStyle = BS_SOLID;

	HBRUSH hBrush = CreateBrushIndirect(&logBrush);

	SelectObject(hDC,hBrush);

	SelectObject(hDC,hPen);

	Rectangle(hDC,rand()%ClientRect.right,rand()%ClientRect.bottom,rand()%ClientRect.left,rand()%ClientRect.top);

	DeleteObject(SelectObject(hDC,GetStockObject(BLACK_BRUSH)));
	DeleteObject(SelectObject(hDC,GetStockObject(BLACK_PEN)));

	ReleaseDC(g_hWndMain,hDC);

	return 0;
}

int GameShutdown()
{
	return 0;
}