Active Template Library
Developer(s) | Microsoft |
---|---|
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 very quickly with a minimum of hand coding. On the COM client side ATL provides smart pointers that deal with COM reference counting.
History and use
Controls for the Internet market could have been made with the Microsoft Foundation Classes (MFC), but the market requires controls to be small and compact for downloading over the network from Web servers. MFC applications tend to be large and require support DLLs.[3] ATL allows creating smaller controls without support DLLs, so ATL is in a sense a lightweight alternative to MFC for the COM control environment.
A common use of ATL in Active Server Pages (ASP) is to construct objects that can be called from a script. While limited in certain respects, VBScript is able to call C++ Windows code contained in a COM object. In ATL version 7 (Visual Studio 2003), which directly succeeded version 3 (Visual Studio 6.0), a number of MFC classes like CString have been made available in ATL, or more precisely have been moved to an ATLMFC common layer which is shared by both libraries. ATL version 7 also introduced attributes in C++ using numerous behind the scene tricks (macros, even registry entries) 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, which unlike their entirely-macro-based predecessors balance safety and performance: the stack allocation for the converted string is now limited to a size specified at compile-time (via a template parameter) and above that watermark heap allocation is performed.
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.[4]
Support classes
ATL includes many RAII classes to simplify management of COM types. The most commonly used classes include:
CComPtr<T>
[5] general-purpose smart-pointer,CComBSTR
[6] BSTR wrapper,CComVariant
[7] VARIANT wrapper, andCComSafeArray<T>
[8] SAFEARRAY wrapper.
See also
References
- ^ Grimes, Richard (1998). "ATL and COM". ATL COM (1st edition ed.). Wrox Press. p. 6. ISBN 1-86100-249-1.
{{cite book}}
:|edition=
has extra text (help) - ^ Grimes, Richard (1999). "Building and calling a COM object using ATL". Beginning ATL 3 COM Programming (1st edition ed.). Wrox Press. p. 63. ISBN 978-1-86100-120-7.
{{cite book}}
:|edition=
has extra text (help) - ^ Williams, Mickey (2000). "Active Documents". Visual C++ 6 Unleashed (1st edition ed.). Sams. p. 733. ISBN 978-0-672-31241-0.
{{cite book}}
:|edition=
has extra text (help) - ^ "ATL Security Update". MSDN. Microsoft. 2009-07-28. Retrieved 2011-09-19.
- ^ Microsoft MSDN: CComPtr Class
- ^ Microsoft MSDN: CComBSTR Class
- ^ Microsoft MSDN: CComVariant Class
- ^ Microsoft MSDN: CComSafeArray Class