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.
(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)
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:
#define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
#define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)
which somehow doesn't work in 64bit OS.
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.
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:
If you don't do that, you won't be able to start the application on 64bit system.
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.