World Library  
Flag as Inappropriate
Email this Article

Active Template Library

Article Id: WHEBN0000846960
Reproduction Date:

Title: Active Template Library  
Author: World Heritage Encyclopedia
Language: English
Publisher: World Heritage Encyclopedia

Active Template Library

Active Template Library
Developer(s) Microsoft
Development status Current
Written in C++
Operating system Microsoft Windows
Type Library or framework
License Proprietary

The Active Template Library (ATL) is a set of template-based C++ classes developed by Microsoft, intended to simplify the programming of Component Object Model (COM) objects. The COM support in Microsoft Visual C++ allows developers to create a variety of COM objects, OLE Automation servers, and ActiveX controls.[1][2] ATL includes an object wizard that sets up primary structure of the objects quickly with a minimum of hand coding. On the COM client side ATL provides smart pointers that deal with COM reference counting. The library makes heavy use of the Curiously recurring template pattern.


  • History 1
  • Support classes 2
  • Compiler COM support 3
  • See also 4
  • References 5
  • External links 6


COM objects can also be created with Microsoft Foundation Classes (MFC), but this leads to larger binaries that require support DLLs.[3] ATL, on the other hand, is a more lightweight alternative in situations where the graphical user interface parts of MFC are not required.[4]

In ATL version 7 (Visual Studio 2003), which directly succeeded version 3 (Visual Studio 6.0), a number of MFC classes like CString were made available in ATL, or more precisely moved to an ATLMFC common layer which is shared by both libraries. ATL version 7 also introduced attributes in C++ in an attempt to provide something similar to CLI attributes, however these have not been particularly successful, and have been deemphasized in ATL version 8 (Visual Studio 2005); the various wizards no longer generate them by default. Version 7 also introduced new string conversion classes.

On July 28, 2009, Microsoft released a patch to ATL to fix a bug that could allow ActiveX controls created using ATL to be vulnerable to a remote code execution security flaw.[5]

Since Visual Studio 2013, ATL code in Visual C++ 2013 is static, eliminating the DLL.[6]

Support classes

ATL includes many RAII classes to simplify management of COM types. The most commonly used classes include:

  • CComPtr[7] general-purpose smart-pointer,
  • CComBSTR[8] BSTR wrapper,
  • CComVariant[9] VARIANT wrapper, and
  • CComSafeArray[10] SAFEARRAY wrapper.

Compiler COM support

Although not formally part of ATL, Microsoft Visual C++ also includes additional C++ RAII classes to simplify management of COM types. These compiler COM support classes can be used as replacement for or in combination with ATL, and includes:

  • _com_ptr_t[11] smart-pointer that decorates the COM interface name with a "Ptr" suffix,
  • _bstr_t[12] BSTR wrapper,
  • _variant_t[13] VARIANT wrapper, and
  • _com_error[14] HRESULT wrapper.

Note that as of Visual Studio 2012, the compiler COM support classes does not include a SAFEARRAY wrapper.

See also


  1. ^ Grimes, Richard (1998). "ATL and COM". ATL COM (1st ed.). Wrox Press. p. 6.  
  2. ^ Grimes, Richard (1999). "Building and calling a COM object using ATL". Beginning ATL 3 COM Programming (1st ed.). Wrox Press. p. 63.  
  3. ^ Williams, Mickey (2000). "Active Documents". Visual C++ 6 Unleashed (1st ed.). Sams. p. 733.  
  4. ^ Microsoft MSDN: Recommendations for Choosing Between ATL and MFC
  5. ^ "ATL Security Update". MSDN. Microsoft. 2009-07-28. Retrieved 2011-09-19. 
  6. ^ ATL and MFC changes and fixes in Visual Studio 2013
  7. ^ Microsoft MSDN: CComPtr Class
  8. ^ Microsoft MSDN: CComBSTR Class
  9. ^ Microsoft MSDN: CComVariant Class
  10. ^ Microsoft MSDN: CComSafeArray Class
  11. ^ Microsoft MSDN: _com_ptr_t Class
  12. ^ Microsoft MSDN: _bstr_t Class
  13. ^ Microsoft MSDN: _variant_t Class
  14. ^ Microsoft MSDN: _com_error Class

External links

  • Official MSDN reference documentation
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Hawaii eBook Library are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.