GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 21-Dec-2007, 01:36
SimonP SimonP is offline
New Member
 
Join Date: Dec 2007
Posts: 6
SimonP is on a distinguished road

Problem with "#include <windows.h>" in Visual C++ 2005 Express Edition


Hi guys I'm in the process of attempting to write a small program that will capture an image of a window. I am writing a class CaptureScreen which will capture the images from the windows. The CaptureScreen header file "CaptureScreen.h" is as follows:

CPP / C++ / C Code:
#ifndef CAPTURESCREEN_H
#define CAPTURESCREEN_H
#include <windows.h>

class CaptureScreen
{
public:
	CaptureScreen();
	~CaptureScreen();
	bool CaptureWindow(HWND hWndSrc,double fPreviewRatio ,LPTSTR lpszFileName,BOOL bSaveToFile);
private:
	int width;
	int heigh;
	int bpp;
}

#endif

Where should I put the #include <windows.h> statement? I presume that it needs to be somewhere in the header file otherwise the HWND class will not be recognized by the compiler as a valid identifier.
Also, when I try to compile the above code, I get the following error message:

Code:
1>------ Build started: Project: ScreenScraper, Configuration: Debug Win32 ------ 1>Compiling... 1>ScreenScraper.cpp 1>c:\users\simon\documents\visual studio 2005\projects\screenscraper\screenscraper\capturescreen.h(3) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory 1>CaptureScreen.cpp 1>c:\users\simon\documents\visual studio 2005\projects\screenscraper\screenscraper\capturescreen.h(3) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory 1>Generating Code... 1>Build log was saved at "file://c:\Users\Simon\Documents\Visual Studio 2005\Projects\ScreenScraper\ScreenScraper\Debug\BuildLog.htm" 1>ScreenScraper - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have the following directories in my Tools-Options-VC++ Directories-Show directories for: Include files:
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(VCInstallDir)PlatformSDK\include\prerelease
$(VCInstallDir)PlatformSDK\common\include\prerelea se
$(VCInstallDir)PlatformSDK\include
$(VCInstallDir)PlatformSDK\common\include
$(FrameworkSDKDir)include

Any advice as to why this won't compile would be greatly appreciated.

Sincerely,

Simon Pearson
  #2  
Old 21-Dec-2007, 03:34
inevitable inevitable is offline
Junior Member
 
Join Date: Nov 2007
Posts: 53
inevitable is on a distinguished road

Re: Problem with "#include <windows.h>" in Visual C++ 2005 Express Edition


If you can provide me the .cpp file, then may be I can help you.
  #3  
Old 21-Dec-2007, 07:30
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,627
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Problem with "#include <windows.h>" in Visual C++ 2005 Express Edition


Quote:
Originally Posted by SimonP
CPP / C++ / C Code:
#include <windows.h>


Code:
1fatal error C1083: Cannot open include file: 'windows.h': No such file or directory 1>CaptureScreen.cpp 1>c:\users\simon\documents\visual studio 2005\projects\screenscraper\screenscraper\capturescreen.h(3) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

I have the following directories in my Tools-Options-VC++ Directories-Show directories for: Include files:
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(VCInstallDir)PlatformSDK\include\prerelease
$(VCInstallDir)PlatformSDK\common\include\prerelea se
$(VCInstallDir)PlatformSDK\include
$(VCInstallDir)PlatformSDK\common\include
$(FrameworkSDKDir)include

So: Is windows.h (or Windows.h or any other thing like windows.h) in any of these directories?

The 2005 distribution did not include windows.h (or any of the windows API libraries required to actually create windows applications). PlatformSDK also did not include them, as I recall. There were some rather detailed instructions on the Microsoft site from which I downloaded the compiler package that showed how to obtain and install the SDK for Windows applications. I don't know whether it is still there or is still valid. (You might consider getting a later version of compiler from Microsoft. Still free.)

Bottom line: If you have windows.h somewhere in the "Microsoft Visual Studio 8" directory tree, you must make sure that that directory is in the include path. (You must also put the lib directory with the .dll and .lib files on the path that the linker can find.)


Regards,

Dave
  #4  
Old 21-Dec-2007, 09:22
TurboPT's Avatar
TurboPT TurboPT is online now
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 926
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Problem with "#include <windows.h>" in Visual C++ 2005 Express Edition


Quote:
Originally Posted by davekw7x
PlatformSDK also did not include them, as I recall. There were some rather detailed instructions on the Microsoft site from which I downloaded the compiler package that showed how to obtain and install the SDK for Windows applications. I don't know whether it is still there or is still valid. (You might consider getting a later version of compiler from Microsoft. Still free.)
True, there were actually about 5 steps [one of which was the PlatformSDK] to get everything needed [to build Win32] for the express edition. Check this post. It contains a link to a Microsoft forum that provides each step with links.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #5  
Old 21-Dec-2007, 15:03
SimonP SimonP is offline
New Member
 
Join Date: Dec 2007
Posts: 6
SimonP is on a distinguished road

Re: Problem with "#include <windows.h>" in Visual C++ 2005 Express Edition


Thanks for all of the helpful replies, I fixed the problem by uninstalling Visual Studio Express Edition 2005,replacing it with Visual Studio Express Edition 2009 and then following the 5 steps in the post linked by TurboPT to install the PlatformSDK.
Is the include <windows.h> statement at the right place in the header file? This compiles but I didn't want to be following any poor coding practices.
 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Experiencing a linking error with MS Visual C++ 2005 Express Edition SimonP CPP / C++ Forum 3 20-Dec-2007 14:34
Major newbie problem cynack MS Visual C++ / MFC Forum 1 08-Apr-2007 11:25
can i run visual 2005 mfc project in visual 6 or 2003? spillover MS Visual C++ / MFC Forum 1 27-Dec-2006 18:09
How Visual C++ only from Visual Studio .net Picstudent .NET Forum 2 28-May-2006 20:52
What is "Ambigious symbol" ??*( a compilation error) small_ticket CPP / C++ Forum 2 07-Jan-2005 21:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:27.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.