Export (0) Print
Expand All

Using C++ Header Files

EWS Managed API

Topic Last Modified: 2006-06-30

This topic lists each Component Object Model (COM) component (or group of components) and provides a table of header files with a brief description of each.

Include file Description

cdoex.h

Contains type information for Collaboration Data Objects (CDO) COM interfaces, COM classes and enumerations.

cdoex_i.c

Contains the GUIDs (CLSID, IID, LIBID) for CDO.

cdoexstr.h

Contains the string constants used with CDO. These include string constants for Exchange and CDO schema fields.

cdoexerr.h

Contains constant definitions for all the CDO custom (FACILITY_ITF) error codes.

adoint.h*

Contains the Microsoft ActiveX® Data Objects (ADO) 2.5 Library type definitions. This header is required for CDO to function. It is automatically included in cdoex.h.

adoid.ic*

Contains GUIDs for ADO interfaces and COM classes.

* The adoint.h header is included automatically in the cdoex.h header file. The adoid.ic source file, however, is not.

For information about using workflow classes in C++, see Using Native COM Support in Microsoft Visual C++.

Component file Description

cdowf.dll

Contains the type library for the CDO Workflow COM interfaces, COM classes, and enumerations.

Include file Description

cdoexm.h

Contains type information for CDO for Exchange Management (CDOEXM) COM classes, interfaces, and enumerations.

cdoexm_i.c

Contains GUID definitions for CDOEXM types.

Aa579067.note(en-us,EXCHG.80).gifNote:
CDO types and ADO types integrate at the interface level. This means that type information supplied by the ADO interface definitions must be present for CDO to work properly. The cdoex.h header file includes a reference to the ADO header file adoint.h. This header file corresponds to the Microsoft ADO 2.5 Library and should be present in the include path. If you plan to create ADO objects directly, you will also need the file adoid.ic. This file contains the GUIDs for ADO COM classes and interfaces.

Include file Description

activeds.h

Contains type information for Active Directory Service Interfaces (ADSI) COM classes, interfaces, and enumerations. Also contains functions and interfaces useful to C++ programmers. See the ADSI documentation for more information.

Include File Description

oledb.h

Contains type information for OLE DB COM classes, interfaces, and enumerations. Also contains functions and interfaces useful to C++ programmers. See the OLE DB 2.5 documentation for more information.

oledberr.h

Contains error constants used when programming with OLE DB interfaces. See the OLE DB 2.5 documentation for more information.

Aa579067.note(en-us,EXCHG.80).gifNote:
When working in C++, you can take advantage of exposed OLE DB interfaces on CDO and ADO objects. If you plan to do so, you should include the OLE DB headers listed in the preceding table. These interfaces, however, are not required.

In many cases, the use of the "using" namespace XXX directive significantly reduces the resolution tasks required by the compiler; this decreases build times significantly.


#include "cdoex.h" 
#include "cdoex_i.c" 
using namespace CDO;
...code...

If you define CDO_NO_NAMESPACE before you include a CDO header file, the CDO namespace is removed from the type information, as shown in the following example:


#define CDO_NO_NAMESPACE 
#include "cdoex.h" 
#include "cdoex_i.c"
...code...

When coding in C++, you can include other type declarations that conflict with CDO types. For example, mapidefs.h contains an IMessage type, which produces an error when you attempt to program using both cdoex.h and mapidefs.h. The solution to such conflicts is to use namespaces and then explicitly reference all redundant types, as in the following example:


#include "cdoex.h"
#include "cdoex_i.c"
#include "mapidefs.h"
...
CDO::IMessage* pCDOMessage;
::IMessage* pMAPIMessage;

In the following example, all CDO types are explicitly prefixed with the CDO C++ namespace:


#include "cdoex.h"
#include "cdoex_i.c"
#include "cdoexstr.h"
#include "cdoexerr.h"

#include "cdoexm.h"
#include "cdoexm_i.c"

void main() 
{
  CoInitialize(NULL);
  CDO::IMessage*    pMsg    = NULL;
  CDO::IDataSource* pDsrc   = NULL;

  HRESULT hr = CoCreateInstance(CDO::CLSID_Message,
                               NULL,
                               CLSCTX_INPROC_SERVER,
                               CDO::IID_IMessage,
                               reinterpret_cast<void**>(&pMsg));
  hr = pMsg->QueryInterface(CDO::IID_IDataSource, reinterpret_cast<void**>(&pDsrc));

  CDOEXM::IMailRecipient* pMbrecip  = NULL;
  hr = CoCreateInstance(CDOEXM::CLSID_Mailbox,
                               NULL,
                               CLSCTX_INPROC_SERVER,
                               CDOEXM::IID_IMailRecipient,
                               reinterpret_cast<void**>(&pMbrecip));
// ...

  CoUninitialize();

}

This example imports the CDO namespace into the default, global namespace with the C++ "using" namespace directive. In this case, you need not use the CDO:: namespace prefix. However, if other types exist with these names, conflicts can occur. For example, MAPI also defines a type called IMessage and having MAPI headers in the same module causes a conflict. To avoid such conflicts, you should use the CDO namespace.


#include "cdoex.h"
#include "cdoex_i.c"
#include "cdoexstr.h"
#include "cdoexerr.h"
using namespace CDO;

#include "cdowf.h"
#include "cdowf_i.c"
// Using namespace CDOWF;

#include "cdoexm.h"
#include "cdoexm_i.c"
// Using namespace CDOEXM;

void main() 
{
  CoInitialize(NULL);
  IMessage*    pMsg    = NULL;
  IDataSource* pDsrc   = NULL;

  HRESULT hr = CoCreateInstance(CLSID_Message,
                               NULL,
                               CLSCTX_INPROC_SERVER,
                               IID_IMessage,
                               reinterpret_cast<void**>(&pMsg));
  hr = pMsg->QueryInterface(IID_IDataSource, reinterpret_cast<void**>(&pDsrc));

...

  CoUninitialize();

}

Show:
© 2015 Microsoft