Thursday, August 20, 2009

Creating Win32 application with Visual C++ Express Edition

I am a C/C++ programmer. C++ programming language is my favourite programming language. There are many programming IDEs (Integrated Development Environment) for C++ programmers such as Microsoft Visual C++, Dev C++, Code::Block C++ IDE, Eclip for C++ development, etc.

Among them, probably the most popular C++ IDE is Microsoft’s Visual C++. Although we cannot get Microsoft Visual C++ Professional Edition for free, we can freely download Visual C++ Express Edition from Microsoft web site. Visual C++ Express Edition is created for beginners, students and hobbyists. However, that Microsoft’s Visual C++ Express Edition is quite enough for OpenGL or DirectX programming and even for simple game projects. The current version of Visual C++ Express Edition is 2008.

The bad thing about Visual C++ Express Edition is that it does not have libraries and headers to create native Win32 applications. Game programs that are based on OpenGL or Microsoft’s DirectX API should be created in pure Win32 style. Win32 project is sufficient for games and real-time graphic rendering programs. We don’t need to use dot NET or MFC (Microsoft Foundation Class) libraries for game and graphic programming.

To create Win32 application with Microsoft Visual C++ Express Edition, we need to download and install Microsoft’s Platform SDK (Software Development Kit) or Windows SDK. For those who are using Windows Vista, I think they should use Windows SDK which is the latest SDK for Win32 creation. After we have downloaded Platform SDK or Windows SDK, all we need to do is to connect their libraries and headers with Visual C++ Express IDE.

To connect Platform SDK or Windows SDK with Visual C++ Express Edition, open the Tools menu and then select Options. You will see Options dialog box. From the left pane, choose VC++ Directories under Projects and Solutions. We need to add the exact path of the installed folder for Platform SDK or Windows SDK for Include and Libraries files. (See the following picture).

Remember that we need to add the path for the Platform SDK for Windows SDK for both Include Files and Library Files. We can only create Win32 applications with Visual C++ Express Edition only after we have correctly connected the Windows SDK to it.

There is one last thing to do before we can create Win32 applications with Visual C++ Express Edition even after we have connected Platform SDK or Windows SDK to it. We need to edit the small file called corewin_express.vsprops under the installed folder of Visual C++ Express. You can open it with Notepad or any other text editing program. You can see the following line in that file - AdditionalDependencies="kernel32.lib". Replace that line with the following line and save the file. AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib". This is needed to add additional Win32 libraries to Visual C++ Express Edition. Otherwise, we might get error in runtime at some points.

After we have connected Platform SDK or Windows SDK with Visual C++ Express and we have edited the corewin_express.vsprops file, we can start to create Win32 graphic applications or games with OpenGL, DirectX or SDL (Simple Direct Media Layer) APIs.

2 comments:

  1. So nice blog. :) Thank you, Ko Thiha.

    ReplyDelete
  2. I have heard about the Visual C++ that People make fewer mistakes in consistent environments, Programmers can go into any code and figure out what's going on, People new to C++ are spared the need to develop a personal style and defend it to the death, People new to C++ are spared making the same mistakes over and over again, Programmers have a common enemy.

    ReplyDelete