
ATLexe Example
This example builds an out-of-proc (exe) multi-threaded server that
implements the ISum interface. Its purpose is to show how to build
components with the Active Temple Library (ATL). The files generated
are:
1. ATLexe.idl โ IDL file created by the ATL Object wizard from
developer inputs. The IDL describes the ISum interface and class
object.
๏ทmanual page tells you how to create this example using ATL and
its wizards.
2. ATLclient.cpp โ created entirely by the developer. It imports the
type library, generated by midl from its IDL file. The type library
import brings in header files which:
๏ทdeclare the component and interface IDs
๏ทdeclare smart pointers and wrapper functions for the inteface.
The wrapper functions simply call your interface methods and
throw exceptions if any errors occur.
๏ทdeclare an error class, _com_error. The exceptions throw objects
of this class and you can extract strings describing the error from
them (see client code).
3. Sum.h โ created by ATL Object wizard, provides a class declaration
for the component (actually, the real component is derived from this
class to add implementations for the class factory and component
IUnknown interface.
4. Sum.cpp โ created by ATL and modified by the developer to provide
semantics for the interface implementation.
5. ATLexe.cpp โ generated by the ATL Application Wizard. Provides
the server dll export functions.
6. stdafx.h and stdafx.cpp โ declarations and includes for ATL imple-
mentation code.
7. ATLexe.rc โ resource file for project
8. ATLexe.rgs โ registry script for class object
9. Sum.rgs โ registry script for ISum interface
10. resource.h โ defines some internally used identifiers
When the midl compiler is run it will generate the additional files:
1. ATLexe.h โ interface declarations for component, proxy, and stub.
2. ATLexe.tlb โ type library file
3. ATLexe_i.c โ define GUIDS
4. ATLexe_p.c โ proxy/stub code
Note that a proxy is needed for this demo so these files are included in
the projects.