Migrated custom C++/CDOSYS app throws compiler errors

Recently I was working with one of the developer who earlier designed an CDOSYS based mail component in his C++ application built using earlier Visual Studio (2005) version . After migration to VS 2008 environment, they noticed compile errors with the same code/no changes made. When I debugged further and noticed that the msado15.tlh and cdosys.tlh are not generated correctly for some reasons. When I compared the .tlh file generated by previous VS version, i noticed differences in it – as couple of keywords are missing in method definitions in the .tlh file generated by VS previous versions. That’s the reason, they noticed the compile time/linker errors.

The generation of .tlh files is affected by some codes in this project, which is compiled earlier than the import sentences. So i moved the import sentences to the very beginning of stdafx.h and used #import attribute “rename” to avoid any name collusion problems. 

 ...
 #import "c:/program files/common files/system/ado/msado15.dll" rename("ADODB","CDO") rename( "EOF", "adoEOF" ) 
 #import  <cdosys.dll>
 ...

+ Then i tried the changes in the code where they use msado15.dll and cdosys.dll:

Visual Studio - Code

After the above changes, I can successfully compile it without any errors. It helped them to move ahead.

Visual Studio Output

Happy debugging!!