Click here to Skip to main content
Click here to Skip to main content

Using WTL with Visual C++ 2005 Express Edition

By , 13 Jan 2006
 

Introduction

Visual C++ 2005 Express Edition was released on 11/7/2005. It has a great native C++ compiler and a smart editor. The best thing is that it is free. We can use it for our WTL programming for free. I posted the procedure for the same here on 11/9/2005. Now, I am submitting it to CodeProject.

Step by step

  1. Download and install Visual C++ 2005 Express Edition from MSDN.
  2. Download and install the Platform SDK, and update the Visual C++ setting as detailed here.
  3. Update the Visual C++ directories in the Projects section of the Options dialog box. Add the ATL path to the Include files (the path shown is the default, use the path to your actual location):
    C:\Program Files\Microsoft Platform SDK\include\atl
  4. Change atlwin.h and atlbase.h in the ATL folder of the Platform SDK install as follows:
    • Change SetChainEntry function at line 1725 of atlwin.h - define "int i" at the first line of the function body.
      BOOL SetChainEntry(DWORD dwChainID, CMessageMap* pObject, DWORD
      dwMsgMapID = 0)
      {
          int i;
          // first search for an existing entry
          
          for(i = 0; i < m_aChainEntry.GetSize(); i++)
    • Change AllocStdCallThunk and FreeStdCallThunk at line 287 of atlbase.h to the new macros:
      /* 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)
  5. Download and install WTL from SourceForge:
  6. Download the AppWizard for Visual Studio 2005 Express from the link above this page, unzip and copy the JS file into the WTL\AppWiz folder, double click it to install the WTL Wizard into VC Express.

Enjoy WTL and VC Express free!

Some Problems

Because VC++ Express doesn't include a "Resource Editor", you will get an error when creating a Dialog or FormView. But, once the project and source files are created, you can open the project directly. If you can find a free resource editor, please tell me.

Comments: rvRoman told us of a free resource editor, and tsehonkit gave us a right link.

History

  • 1/12/2006 - first submit, for WTL7.5.
  • 1/27/2006 - fixed an editing error.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Baryon Lee
Web Developer
Japan Japan
Member
I write software and share it to make our life more easy and interesting.
Welcome to my site:Share our software. Love Programming, Love Life.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
NewsFree Resource EditormemberGiermann29 Jun '10 - 21:17 
Since radasm.com seems to be dead, I found another good one:
 
http://www.resedit.net/
GeneralUsing Windows SDK instead of Platform SDK on VISTAmemberfranzzoa21 Jun '10 - 4:28 
I am trying to build qgis using ms visual studio. I am doing it on VISTA I am not sure how I carry on the following on VISTA since Platform SDK has been superceded by the Windows SDK?
 
I am supposed to edit the <vsinstalldir>\Common7\Tools\vsvars file as follows:
 
Add %PlatformSDKDir%\Include\atl and %PlatformSDKDir%\Include\mfc to the
@set INCLUDE entry.
 
But I cannot find the path because, apparently the path does not apply to the Windows SDK installation I have done on my VISTA.
 
Please help me understand how to go on.
 
Franz
GeneralBuilding x64 with VC ExpressmemberT800G5 Apr '10 - 6:39 
64-bit targets can be built with VC Express + WinSDK combo as described here:
Visual C++ 2008 Express Edition And 64-Bit Targets
 
Easy as a pie. Cool | :cool:
NewsATL 7.1 available!memberT800G27 Aug '09 - 11:24 
Now you can get ATL 7.1 from the Windows Driver Kit Version 7.0.0 (Insert "Homer Simpson Woohoo!" here).
No need to modify atlwin.h or atlbase.h, and you get all the good stuff like CAtlFile etc., free as in a free beer.Cool | :cool:
 
Since the WTL wizard generates files for ATL3 (a bit old ver. but works with VC2008 without a glitch), you need to tweak generated stdafx.h a bit.
// Support for VS2005 Express & SDK ATL
#ifdef _WTL_SUPPORT_SDK_ATL3
//////////////////////////////////
// #define _CRT_SECURE_NO_DEPRECATE//<--not neccesarry
// #pragma conform(forScope, off)//
//////////////////////////////////
  #pragma comment(linker, "/NODEFAULTLIB:atlthunk.lib")
#endif // _WTL_SUPPORT_SDK_ATL3

#include <atlbase.h>
#include <atlstdthunk.h> //<--must add this here!!! (ATL3 defines _stdcallthunk in atlbase.h, ATL7 in atlstdthunk.h)
Hopefully new WTL wizard will add macro switches for ATL 3/7 (_ATL_VER == 0x0300 /_ATL_VER == 0x0800).
 
Optionally, you can define __AllocStdCallThunk/__FreeStdCallThunk as
namespace ATL
  {
	inline void * __stdcall __AllocStdCallThunk()
	{
		return ::VirtualAlloc(0, sizeof(_stdcallthunk), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
	}
 
	inline void __stdcall __FreeStdCallThunk(void *p)
	{
		if (p) ::VirtualFree(p, 0, MEM_RELEASE);
	}
 };
it works in 32 bit and is (haven't tested myself) 64 bit-ready, just like dataman64bit said in a previous post.
GeneralRe: ATL 7.1 available!membertlj499929 Jan '11 - 14:28 
Not sure why people are recommending removing atlthunk.lib from builds and defining your own alloc\dealloc functions... that makes no sense. Why not use these functions from the provided atlthunk.lib?
 
Can't talk about WTL, but if you're just looking to use ATL 7.1 with your project, then you can just add the lines below to your project's stdafx.h to take care of x86, x64 and Itanium compilation:
 
#if defined(_M_IX86) || defined(_M_AMD64)
#pragma comment(lib, "atlthunk.lib")
#elif defined(_M_IA64)
#pragma comment(lib, "atl21asm.lib")
#endif
 
This makes sure that these files are included in your project (based on Windows Driver Kit v7.1 - 7600.16385.1 paths):
\lib\ATL\i386\atlthunk.lib
\lib\ATL\amd64\atlthunk.lib
\lib\ATL\ia64\atl21asm.lib
 
On x86 and x64 atlthunk.lib contains the missing __AllocStdCallThunk and __FreeStdCallThunk symbols. On Itanium atl21asm.lib includes the missing _StdCallThunkProcProc symbol.
 
FYI, if you get a message about missing olepro32.lib, then you need to change your library files path to include the proper version of olepro32.lib. There are several versions located in different folders. Use the folder for the minimum operating system you want to support (wxp for WinXP, wnet for Win2K3 and WinXP x64, wlh for Vista, win7 for Win7). Older WDKs may have additional operating system folders, these are the only ones found in WDK 7.1.
AnswerDo it like thismemberT800G7 Jun '11 - 8:21 
This is how I do it lately, it's DEP/x64 compatible and works fine on VC 2008 Express and Pro.
...
// Support for VS2005 Express & SDK ATL
#ifdef _WTL_SUPPORT_SDK_ATL3
#if (_ATL_VER<0x0800)
    #define _CRT_SECURE_NO_DEPRECATE
    #pragma conform(forScope, off)
#endif
#pragma comment(linker, "/NODEFAULTLIB:atlthunk.lib")
#endif // _WTL_SUPPORT_SDK_ATL3

#include <atlbase.h>
 
// Support for VS2005 Express & SDK ATL
#ifdef _WTL_SUPPORT_SDK_ATL3
#if (_ATL_VER>=0x0800)
    #ifndef __ATLSTDTHUNK_H__
    #include <atlstdthunk.h> // _stdcallthunk definition
    #endif
#endif
  namespace ATL
  {
	inline void * __stdcall __AllocStdCallThunk()
	{
		return ::VirtualAlloc(0, sizeof(_stdcallthunk), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
	}
 
	inline void __stdcall __FreeStdCallThunk(void *p)
	{
		if (p) ::VirtualFree(p, 0, MEM_RELEASE);
	}
  };
#endif // _WTL_SUPPORT_SDK_ATL3

#include <atlapp.h>
...

NewsWTL 8.1memberT800G12 May '09 - 10:41 

WTL 8.1 , new release May 7, 2009
Cool | :cool:
IT'S ALIVE!
IT'S ALIVE!
MUAHAHAHAHAHA Big Grin | :-D
 
Just did a quick run, and now it compiles cleanly at warning level 3.Thumbs Up | :thumbsup:
Generalx64 warning!memberdataman64bit24 Aug '08 - 5:43 
When you're using windows x64 and compiling for windows x64, don't replace __AllocStdCallThunk and __FreeStdCallThunk with HeapAlloc/HeapFree. By default, windows x64 has memory execution protection and will NOT run thunk code ATL is using and your application process will lock with no error message. Use this code instead:
 
void* __stdcall __AllocStdCallThunk()
{
LPVOID mem = VirtualAlloc(0, sizeof(_stdcallthunk), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (!mem) return 0;
return mem;
}
 
void __stdcall __FreeStdCallThunk(void* ptr)
{
if (!ptr) return;
VirtualFree(ptr, 0, MEM_RELEASE);
}
 
This code marks allocated memory as executable and application will work again. Thanks for your thanks Smile | :)
GeneralATL only in Platform SDK 2003memberT800G2 Aug '08 - 14:26 
Just for the record, ATL (version 3) comes only with the Platform SDK 2003 (R2), newer versions are only vanilla win32.Frown | :(
Somebody in Microsoft probably realized that you don't need VS Pro if you can get hold of ATL files/headers (even "old" version 3 headers work great with WTL 8.0 and compile at level 3 warnings in VC2005 Express), so go get them while they're still available.Cool | :cool:
Generalvideo streamingmemberagachouch15 Jul '08 - 10:47 
hallo erstmal,
ich möchte ein video(h.264/oder egal was für ein videocodec) peer to peer über internet streamen(RTP ODER udp),und hierfür ein programm in c++ oder c# schreiben , das diese funktion "streaming" ausführt.
ich wäre für jede Hilfe sehr dankbar.
 
danke voraus.
agach
Generalwindows vista + Windows (aka Platform) SDK + atlthunk.lib + winnt.h errors -- what worked for mememberMember 274734928 Apr '08 - 4:22 
While trying to get some Direct Show stuff working on Vista with VC++ 2008 Express Edition on Vista and the new renamed Windows SDK (known b4 as Platform SDK) I got errors like "Cannot open atlthunk.lib"
Which many others seemed to have got for different VS versions.....
The one which says comment the pragma does not work for the versions i have...bcause the header doesnt have such a pragmaConfused | :confused: .
 
What worked: create a dummy empty lib in the VC++ version you are using. Shucks | :->
DO NOT copy the lib to where you want - you get some manifest errors ... either create the lib in the dir you want or give the path of where it was placed by VC.
 
I dont know if its related but after this i got some errors in winnt.h in the line
typedef void * POINTER_64 PVOID64;
 
i commented it and replaced it with
typedef void * __ptr64 PVOID64;
 
and it worked.
QuestionVc 2008 express and WTL ?memberIvan Mladenovic19 Feb '08 - 1:39 
Hello !
Has anyone tried to make WTL Work with visial c++ express 2008 edition?
 
www.tigar.com

QuestionRe: Vc 2008 express and WTL ?memberKin Hoon4 Mar '08 - 2:38 
It seems that ATL headers are not included in latest Windows SDK anymore.
 
Since WTL depends on ATL, does it means that we are no longer able to use VC Express + Windows SDK + WTL to build GUI application? Correct me if I am wrong.
 
Any other free GUI framework that we can use to develop Windows based GUI application? Any suggestion?
GeneralRe: Vc 2008 express and WTL ?memberIvan Mladenovic5 Mar '08 - 0:27 
Hm ... , My primary concern is WTL , but other options are: WxWidgets , SmartWin++ , FLTK , maybe Qt becaouse of licensing restriction ( gpl-ed and commertial licenese ) .
Anyway , I can always use VC express 2005 .
 
www.tigar.com

GeneralRe: Vc 2008 express and WTL ?member9844062216 Mar '08 - 2:44 
Yesterday, my computer is attacked by virus. I deceided to update the OS from WINXP(sp2) to VISTA. It seemed that all things went well first until i was porting my project based on WTL to the new platform. I downloaded the latest SDK and installed it. After that, I installed VS2008 express and began to build my project while I found there's no ATL head files in the SDK directiory! Does someone have some soultion for my problem?
AnswerRe: Vc 2008 express and WTL ?membertsehonkit23 Aug '08 - 6:53 
Yes, I just use windows WDK_6001_18001 for atl. Modifly the wtl setupexpress80.js script from version 8 to version 9. All other procedure are the same as this topic. Then I can compile a simple dialogue base wtl for testing. So, you can try and see if there are any other problems exist. I am not a wtl programmer and just start my learning. one more thing, I did not follow the auther to modifly the atl code. Just install WDK and setup the correct path for atl inside VC 2008 express only.
QuestionWTL wizzard doesn't workmemberMember 165025331 Jan '08 - 22:34 
When I want to crate a WTL-project I get the following message :
Line 394
Character 2
Error Object attended (in French "Erreur objet attendu")
Code 0
URL fille///C:/WTL/AppWiz/Files/HTML/1053/default.htm
When I look in the Html code of default.htm
I find on line 394 setDirection();
This is in the function :
function InitDocument(document)
The result is that I get Only the default page and cannot make choices.
Can anyone help me?
AnswerRe: WTL wizzard doesn't workmemberoromero8 Jul '08 - 5:17 
Juste replace in the wizard *.html the GetHostLocale by your languageId (1033 for french) at the top and the bottom files.
QuestionError while creating a plugin for windows media player.memberamiya das4 Jan '08 - 2:08 
Hi,
 
I am using VC++ express edition 2005,WMPPSDK 9.0,WMFSDK 9.0 and PSDK.
 
i took the code from
http://download.microsoft.com/download/4/8/f/48f553fc-cdca-403c-b6aa-09de38559cd3/Connect_Plugins_Samples.EXE[^]
 
when i executed project wmplayerpluginagent it gave me the following errors.
 
------ Build started: Project: WMPlayerPluginAgent, Configuration: Debug Win32 ------
Compiling...
stdafx.cpp
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3242) : error C2065: '_Module' : undeclared identifier
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3242) : error C2228: left of '.Lock' must have class/struct/union
type is ''unknown-type''
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3244) : error C2228: left of '.Unlock' must have class/struct/union
type is ''unknown-type''
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3366) : error C2228: left of '.CreateInstance' must have class/struct/union
type is ''unknown-type''
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3373) : error C2228: left of '.Lock' must have class/struct/union
type is ''unknown-type''
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3375) : error C2228: left of '.Unlock' must have class/struct/union
type is ''unknown-type''
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3641) : error C2228: left of '.m_csTypeInfoHolder' must have class/struct/union
type is ''unknown-type''
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3658) : error C2228: left of '.AddTermFunc' must have class/struct/union
type is ''unknown-type''
e:\program files\microsoft platform sdk\include\atl\atlcom.h(3667) : error C2228: left of '.m_csTypeInfoHolder' must have class/struct/union
type is ''unknown-type''
Build log was saved at "file://e:\Connect_Plugins_Samples\WMPlayerPluginAgent\Debug\BuildLog.htm"
WMPlayerPluginAgent - 9 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
 
can any one tell me why it is giving this error.
 
AS

QuestionPlatform SDK = Windows SDK?memberreinux7 Sep '07 - 23:47 
The Windows Vista SDK (which is 1gb) doesn't seem to include atlbase.h. Am looking for the Platform SDK? Because I can only find the Windows 2003 Platform SDK.
 
It drives me nuts how Marketing keeps changing product names.
NewsA Guide to WTL8.0 with VC++2005 expressmemberwbkang23 Jun '07 - 7:42 
Set up vc++ with platform SDK.
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/[^]
 
Add 'include/atl' to your directory settings of vc++.
 
download wtl 8.0.
http://www.microsoft.com/downloads/details.aspx?FamilyID=E5BA5BA4-6E6B-462A-B24C-61115E846F0C&displaylang=en[^]
 
in your directory of wtl(default-c:\wtl8.0), execute appwiz/setup80.js or setup80x.js depending one which one works for you.
 
add c:\wtl80\include to your include directory in vc++ settings.
 
done! try to build wtl app with app wizard.
QuestionOK, but where are atlcoll.h etc?memberCCanadaK3 Apr '07 - 18:21 
A project that I need to build includes the files atlcoll.h, atlstr.h and atltypes.h. Alas, even though I followed the instructions by the letter and installed the complete "Platform SDK for Windows Server 2003 R2", these files are nowhere to be found. Any tips on how to work around this?
 
Thx,
Chris

AnswerRe: OK, but where are atlcoll.h etc?memberEd Gadziemski22 Jan '09 - 10:30 
The headers you mentioned don't come with VC Express Edition, only Professional (maybe Standard?) and above.
Questionmissing the atlthunk.lib ?memberFirkraag11 Nov '06 - 21:02 
I got as far as to linking but now I've been getting the error:
LINK : fatal error LNK1104: cannot open file 'atlthunk.lib'
I have Microsoft Platform SDK for Windows Server 2003 R2 installed.
What more should I get?
AnswerRe: missing the atlthunk.lib ?memberNuno Esculcas9 Feb '07 - 8:20 
Edit your altbase.h there is #pragma comment directive, that queries
for atlthunk.lib - comment this.
 
this is an instruction made in this page by the author, you probably missed to comment the line like i do Poke tongue | ;-P
 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 13 Jan 2006
Article Copyright 2006 by Baryon Lee
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid