Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

WTL Setup Gotchas

0.00/5 (No votes)
7 May 2013 1  
Tips for VC++ 2010 Express users on 64bit Windows.

Introduction

As there is little information (or many obsolete/misleading articles), this is to make life easier for those who want to setup WTL on 64bit Windows and VC++ Express Edition.

Target

(In the brackets, there is the author's configuration.)

  • VC++ Express Edition (VC++ 2010 Express)
  • 64 bit Windows (Windows 7 Home Premium)
  • WTL (WTL 8.1)

ATL Headers

If you have only the free edition of Visual Studio (Express), it comes without ATL headers. After some Googling, you will probably find that you should install "Microsoft ® Windows Server® 2003 R2 Platform SDK" which contains them and fix two header files:

and others. After setting up additional include and linker directories, you will be able to successfully compile your application. But... when you try to start/debug it -oops! Everything crashes on WindowCreateEx(), etc. Why? The problem lies in the fix below, mentioned in the examples:

/* Comment it
PVOID __stdcall __AllocStdCallThunk(VOID);
VOID __stdcall __FreeStdCallThunk(PVOID);

#define AllocStdCallThunk() __AllocStdCallThunk()
#define FreeStdCallThunk(p) __FreeStdCallThunk(p)

#pragma comment(lib, "atlthunk.lib")
*/
#define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
#define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p) 

which somehow doesn't work in 64bit OS.

WDK

The correct way is to install Windows Driver Kit Version 7.1.0, which contains newer version of ATL and file atlthunk.lib, so you don't need the incompatible trick above. You can get it here.

It is not a web installer. You have to download 619 MB CD .iso image. Be careful to download it complete. My first download (done via Google Chrome) somehow truncated the file and KitSetup.exe ended with misleading digital signature verification errors. Not only for me.
You don't need to install Microsoft File Transfer Manager. I was able to download ISO with Internet Explorer 9 correctly.

App Wizard

The next thing you will probably encounter on Vistas and above is that the wizard for creating new project does not work. It says something about errors in a script. This can be easily fixed by unblocking the shipped WTL AppWizard .js files using Windows Explorer: properties - unblock. See the following post 3.

If you install the wizard marked with "x" at the end of its name, which is for Express Editions, there is included the patch above by default. You need to comment the following line in stdafx.h:

// This project was generated for VC++ 2005 Express and ATL 3.0 from Platform SDK.
// Comment out this line to build the project with different versions of VC++ and ATL.
//#define _WTL_SUPPORT_SDK_ATL3 

If you don't do that, you won't be able to start the application on 64bit system.

Final Tips

To globally setup include and linker additional paths in VS 2010, you use the Property Manager. See the MSDN or simply View->Property manager, select Microsoft.Cpp.Win32.user for all configurations (using ctrl-click) and set up everything you need.

Hope it helps.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here