Visual Studio Express 2008 and the Platform SDK


Due to the rise of open source and the competition brought by free compilers like Dev C++ and Code::Blocks, microsoft has had to make windows development more appealing to students and developer hobbyists. To do so they released a stripped down version of its compilers as freeware, Visual Studio Express 2005. It included Visual Basic, C++, C# and ASP. They re-released it again in 2008 with more features.

One of the ways to re-enable many of the stripped down features are to install the Microsoft Platform SDK. An old version is available here (may 2005), but the modern version is called the Microsoft Windows SDK. The major difference is that the Platform SDK can build apps for Windows 2000, XP and Server 2003 while the newer Windows SDK can build apps for XP, Server 2003, Vista and Server 2008.

While you can only use Visual C++ Express 2008 to compile applications for windows, it is still just a C++ compiler and if you use the right libraries you can make your code portable so that it can be compiled on any platform. Here is a step by step installation and configuration of Visual C++ Express 2008.

Installation

1. Download and install Visual C++ Express 2008.

2. Download and install the Windows SDK for Windows Server 2008 iso download or web install
Installing the PSDK for VC++ Express 2008 is much easier than with Visual Studio Express 2005.

Create a test project.

1. In Visual Studio 2008, select File -> New -> Project.

2. Select Win32 Console Application, choose a name, click [Next].

3. Under Application Settings, uncheck Precompiled Header, click [Finish].

4. Copy and Paste the following code:
#include <windows.h>
#include <tchar.h>
#include <shellapi.h>
 
int _tmain(int argc, _TCHAR* argv[])
{
    ShellExecute(NULL, _T("open"), _T("http://www.google.com"), NULL, NULL, SW_SHOW);
    return 0;
}
5. Compile and Execute.

For an detailed explanation of why the win32 API uses _T(), _TCHAR*, LPCTSTR etc, check out part 1 and part 2 of win32 string api detailed guide.

Here is another quick hello world type program that should test whether the win32 api works.


1. In Visual Studio 2008, select File -> New -> Project.

2. Select Win32 Project, choose a name, click [Next].

3. Under Application Settings, check Empty Project, click [Finish].

4. Under Sourcefiles (on the left tree menu), right click, Add -> New Item -> .CPP -> choose a name.

5. Copy and Paste the following code:
#include <windows.h>
#include <tchar.h>
 
#define WIN32_LEAN_AND_MEAN           
 
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  //create the main window
  CreateWindowEx(  
    0, 
    WC_DIALOG, //predefined const WC_DIALOG for dialog boxes
    _T("My Window"), // title text of the window
    WS_OVERLAPPEDWINDOW | WS_VISIBLE, // style
    400, // x
    100, // x
    200, // w
    200, // h
    NULL, // parent window handle -  NULL
    NULL, //  
    NULL, //  
    NULL  //  
  );
 
  //display a message box
  MessageBox(
    NULL, // parent window handle - NULL
    _T("Message - Hello World"),
    _T("Title of Message Box"),  
    0 // style
  );
  return 0;
}
6. Compile and Execute.

Deploy Your Application

To deploy an application, the client will need to download
vcredist_x86.exe for Visual C++ Express 2008. Then the client should be able to run any .exe you have compiled.

Using NSIS and vcredist_x86.exe

There are more details in this article Using NSIS and vcredist.
code snippets are licensed under Creative Commons CC-By-SA 3.0 (unless otherwise specified)