
ATLdemo7 Example
This example builds an in-proc (dll) single-threaded server that
implements the IDemo7 interface. Its purpose is to show how to build
components with the Active Temple Library (ATL). The files generated
are:
1. ATLdemo7.idl โ IDL file created by the ATL Object wizard from
developer inputs. The IDL describes the IDemo7 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. Demo7.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. Demo7.cpp โ created by ATL and modified by the developer to
provide semantics for the interface implementation.
5. ATLDemo7.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. resource.h โ defines some internally used identifiers
When the midl compiler is run it will generate the additional files:
1. ATLDemo7.h โ interface declarations for component, proxy, and
stub.
2. ATLDemo7.tlb โ type library file
3. ATLDemo7_i.c โ define GUIDS
4. ATLDemo7_p.c โ proxy/stub code
Note that no proxy is needed for this demo so they are not included in
the projects.