missing windows.h? SOLVED

Started by
14 comments, last by nemostyle 17 years ago
I just installed VC++2005 Express. I started writing some code, and went to "#include <windows.h>" to access the RECT structure. When I try to compile I get an error that it cannot find windows.h. Does anyone know what's going on, or has had the same problem? [Edited by - trick on March 22, 2007 4:28:29 AM]
Advertisement
Install the Platform SDK.

HTH
Unless im mistaken, the express edition comes only with the C++ standard library by default, and you must download the Microsoft Platform SDK and set your compiler up to use it: http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en

-Andrew
Thanks much!

Got it downloaded, and installed. I started building up a test program to make sure there were no errors, but my compiler is finding errors inside "winnt.h". Errors below, anyone know what may be going on? Also posted below the errors, is code from winnt.h where the errors occur.

Quote:
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(5940) : error C2146: syntax error : missing ';' before identifier 'Buffer'
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

typedef void *PVOID;typedef void * POINTER_64 PVOID64; //line#222

typedef union _FILE_SEGMENT_ELEMENT {    PVOID64 Buffer; //line#5940    ULONGLONG Alignment;}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
Can you please post the code for your test program?
Sure.

//BlockBuster.cpp#include <windows.h>#include <d3d9.h>HINSTANCE hInst;HWND wndHandle;LPDIRECT3D9 pD3D;LPDIRECT3DDEVICE9 pd3dDevice;bool initWindow(HINSTANCE hInstance);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);bool initDirect3D();void update(float x){}void render(){	if(NULL == pd3dDevice)		return;	pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);	pd3dDevice->BeginScene();	pd3dDevice->EndScene();	pd3dDevice->Present(NULL, NULL, NULL, NULL);}void cleanup(){	if(pd3dDevice != NULL)		pd3dDevice->Release();		if(pD3D != NULL)		pD3D->Release();}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){	float last_time = 0.0f;	if(!initWindow(hInstance))		return false;	if(!initDirect3D())		return false;	MSG msg;	ZeroMemory(&msg, sizeof(msg));	float time_total = 0.0f;	while(msg.message != WM_QUIT){		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){			TranslateMessage(&msg);			DispatchMessage(&msg);		}else{		}	}	cleanup();	return 0;}bool initWindow(HINSTANCE hInstance){	WNDCLASSEX wc;	wc.cbSize = sizeof(WNDCLASSEX);	wc.style = CS_HREDRAW | CS_VREDRAW;	wc.lpfnWndProc = (WNDPROC)WndProc;	wc.cbClsExtra = 0;	wc.cbWndExtra = 0;	wc.hInstance = hInstance;	wc.hIcon = 0;	wc.hCursor = LoadCursor(NULL, IDC_ARROW);	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);	wc.lpszMenuName = NULL;	wc.lpszClassName = "Block Buster";	wc.hIconSm = 0;	RegisterClassEx(&wc);	wndHandle = CreateWindow("Block Buster", "Block Buster", WS_OVERLAPPEDWINDOW, 100, 100, 800, 600, NULL, NULL, hInstance, NULL);//replace 100 with CW_USEDEFAULT	if(!wndHandle)		return false;	ShowWindow(wndHandle, SW_SHOW);	UpdateWindow(wndHandle);	return true;}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){	switch(message){	case WM_DESTROY:		PostQuitMessage(0);		break;	}	return DefWindowProc(hWnd, message, wParam, lParam);}bool initDirect3D(){	pD3D = NULL;	pd3dDevice = NULL;	if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))){		return false;	}	D3DPRESENT_PARAMETERS d3dpp;	ZeroMemory(&d3dpp, sizeof(d3dpp));	d3dpp.Windowed = TRUE;	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;	d3dpp.BackBufferCount = 1;	d3dpp.BackBufferHeight = 600;	d3dpp.BackBufferWidth = 800;	d3dpp.hDeviceWindow = wndHandle;	if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wndHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice))){		return false;	}	return true;}

This is entire source code of test program. Very basic, just supposed to initialize directx and a window to display.
Quote:
Microsoft Platform SDK for Windows Server 2003 R2

This is not the Win32 Platform SDK..

You need This one
(Same one posted in Simian Man's post)

Insure to follow all of the instructions (You may need to set up library
and include paths). Also, you may need to edit certain files (as the
instructions direct)

After setting this up, try to build a minimal Win32 program (No Direct3d),
and tell us what happens..
Did you add the Platform SDK include directory to your settings?

I can't give you directions myself because I use VC++ 6, but here's some info from Microsoft's website:

Step 1-2: (install VC++ Express and download Platform SDK)

Step 3: Update the Visual C++ directories in the Projects and Solutions section in the Options dialog box.
Add the paths to the appropriate subsection:

Executable files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin
Include files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include
Library files: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib
Note: Alternatively, you can update the Visual C++ Directories by modifying the VCProjectEngine.dll.express.config file located in the \vc\vcpackages subdirectory of the Visual C++ Express install location. Please make sure that you also delete the file "vccomponents.dat" located in the "%USERPROFILE%\Local Settings\Application Data\Microsoft\VCExpress\8.0" if it exists before restarting Visual C++ Express Edition.



Step 4: Update the corewin_express.vsprops file.
One more step is needed to make the Win32 template work in Visual C++ Express. You need to edit the corewin_express.vsprops file (found in C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults) and

Change the string that reads:

AdditionalDependencies="kernel32.lib"

to

AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"

hackerkey://v4sw7+8CHS$hw6+8ln6pr8O$ck4ma4+9u5Lw7VX$m0l5Ri8ONotepad++/e3+8t3b8AORTen7+9a17s0r4g8OP
the link on that page takes me to a page to download/install...

Microsoft ® Windows Server® 2003 R2 Platform SDK Web Install

Sorry, I'm just not seeing it. This looks like what I did before...
This link?

"Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK"

This topic is closed to new replies.

Advertisement