Active Template Library
{{Infobox software
| name = Active Template Library
| logo =
| screenshot =
| caption =
| collapsible =
| author =
| developer = Microsoft
| released =
| latest release version =
| latest release date =
| latest preview version =
| latest preview date =
| programming language = C++
| operating system = Microsoft Windows
| platform =
| size =
| language =
| genre = Library or framework
| license = Proprietary
| website =
}}{{Short description|Windows development library}}
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.{{cite book | title = ATL COM | edition = 1st | chapter = ATL and COM | page = [https://archive.org/details/atlcomprogrammer00grim/page/6 6] | last = Grimes | first = Richard | year = 1998 | publisher = Wrox Press | isbn = 1-86100-249-1 | chapter-url-access = registration | chapter-url = https://archive.org/details/atlcomprogrammer00grim/page/6 }}{{cite book | title = Beginning ATL 3 COM Programming | edition = 1st | chapter = Building and calling a COM object using ATL | page = [https://archive.org/details/beginningatl3com00grim/page/63 63] | last = Grimes | first = Richard | year = 1999 | publisher = Wrox Press | isbn = 978-1-86100-120-7 | chapter-url-access = registration | chapter-url = https://archive.org/details/beginningatl3com00grim/page/63 }} 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
COM objects can also be created with Microsoft Foundation Classes (MFC), but this leads to larger binaries that require support DLLs.{{cite book | title = Visual C++ 6 Unleashed | edition = 1st | chapter = Active Documents | page = 733 | last = Williams | first = Mickey | year = 2000 | publisher = Sams | isbn = 978-0-672-31241-0 }} ATL, on the other hand, is a more lightweight alternative in situations where the graphical user interface parts of MFC are not required.Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/bk8ytxz5.aspx Recommendations for Choosing Between ATL and MFC]
Older versions of ATL (ATL prior to version 7.1, pre-Visual Studio 2005) are incompatible with DEP because it places executable thunks in data heap.http://web.archive.org/web/20080130115007/http://blogs.msdn.com/michael_howard/archive/2008/01/29/new-nx-apis-added-to-windows-vista-sp1-windows-xp-sp3-and-windows-server-2008.aspxhttps://learn.microsoft.com/en-us/archive/blogs/michael_howard/new-nx-apis-added-to-windows-vista-sp1-windows-xp-sp3-and-windows-server-2008https://msrc.microsoft.com/blog/2009/06/understanding-dep-as-a-mitigation-technology-part-1/
This problem can be mitigated with DEP-ATL thunk emulation with performance penalty.http://web.archive.org/web/20090123222148/http://support.microsoft.com/kb/948468https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute
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.{{cite web|url=http://msdn.microsoft.com/en-us/visualc/ee309358.aspx |title=ATL Security Update |publisher= Microsoft|work = MSDN| date=2009-07-28 |access-date=2011-09-19}}
Since Visual Studio 2013 (ATL version 12), all ATL code is static, eliminating the DLL.http://web.archive.org/web/20130827013146/http://blogs.msdn.com/b/vcblog/archive/2013/08/20/atl-and-mfc-changes-and-fixes-in-visual-studio-2013.aspxhttps://devblogs.microsoft.com/cppblog/atl-and-mfc-changes-and-fixes-in-visual-studio-2013/
ATL version is defined by ATL_VER macros and can be queried via AtlGetVersion() function.https://learn.microsoft.com/en-us/cpp/atl/reference/atl-text-encoding-functions?view=msvc-170#atlgetversion
Support classes
ATL includes many RAII classes to simplify management of COM types. The most commonly used classes include:
CComPtr
Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/ezzw7k98.aspx CComPtr Class] general-purpose smart-pointer,CComBSTR
Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/zh7x9w3f.aspx CComBSTR Class] BSTR wrapper,CComVariant
Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/ac97df2h.aspx CComVariant Class] VARIANT wrapper, andCComSafeArray
Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/3xzbsee8.aspx CComSafeArray Class] 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
Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/417w8b3b.aspx _com_ptr_t Class] smart-pointer that decorates the COM interface name with a "Ptr" suffix,_bstr_t
Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/zthfhkd6.aspx _bstr_t Class] BSTR wrapper,_variant_t
Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/x295h94e.aspx _variant_t Class] VARIANT wrapper, and_com_error
Microsoft MSDN: [https://msdn.microsoft.com/en-us/library/0ye3k36s.aspx _com_error Class] HRESULT wrapper.
Note that as of Visual Studio 2012, the compiler COM support classes does not include a SAFEARRAY wrapper.
See also
References
{{Reflist}}
External links
- [https://msdn.microsoft.com/en-us/library/t9adwcde.aspx Official MSDN reference documentation]
{{Authority control}}