Platform SDK: CDO for Windows 2000 |
The following tables describe the header files you can use when building applications.
Microsoft CDO for Windows 2000
Include file | Description |
---|---|
cdosys.h | Contains type information for CDO COM interfaces, classes, and enumerations. |
cdosys_i.c | Contains the GUIDs (CLSID, IID, LIBID) for CDO. |
cdosysstr.h | Contains the string constants used with CDO. These include string constants for fields. |
|
Contains constant definitions for all of the CDO custom (FACILITY_ITF) error codes. |
|
Contains the ADO 2.5 library type definitions. This header is required for CDO to function. It is automatically included within cdosys.h. |
|
GUIDs for ADO interfaces and COM classes. |
* The adoint.h header is included automatically within the cdosys.h header file. The adoid.ic source file, however, is not.
OLE DB 2.5 Headers
Include file | Description |
---|---|
oledb.h* | Type information for OLE DB COM classes, interfaces, and enumerations. Additionally contains functions and interfaces useful to C++ programmers. See the OLE DB 2.5 documentation for more information. |
oledberr.h* | Error constants used when programming with OLE DB interfaces. See the OLE DB 2.5 documentation for more information. |
These headers are needed only if you wish to use the OLE DB interfaces provided by some of the CDOSYS COM objects. These interfaces are not required to use CDO for Windows 2000 and are present strictly to provide increased performance if desired.
To avoid symbol clashes at compile time, the type information contained within CDO header files resides in the CDO C++ namespace. When referring to these types, you need to define the type's scope. For example, the IMessage interface is referred to as CDO::IMessage. If this namespace scope is not needed in your application, you can import the CDO namespace into the global namespace using the using namespace C++ compiler directive.
In many cases, the using namespace XXX directive will significantly reduce the resolution tasks required by the compiler and therefore decrease build times:
#include "cdosys.h" #include "cdosys_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:
#define CDO_NO_NAMESPACE #include "cdosys.h" #include "cdosys_i.c" ...code...
When coding in C++ you can include other type declarations that may conflict with CDO types. For example, the mapidefs.h
header file contains an IMessage type, which produces an error when attempting to include both cdosys.h
and mapidefs.h
in the same source file. The solution to such conflicts is to use the provided CDO namespaces and then explicitly reference all redundant types. For example:
#include "cdosys.h" #include "cdosys_i.c" #include "mapidefs.h" ... CDO::IMessage* pCDOMessage; ::IMessage* pMAPIMessage;
Using the CDO Namespace
In the following example, all CDO types are explicitly prefixed with the CDO C++ namespace:
#include "cdosys.h" #include "cdosys_i.c" #include "cdosysstr.h" #include "cdosyserr.h" 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)); //... CoUninitialize(); }
Importing the CDO Namespace into the Global Namespace
The following example imports the CDO namespace into the default, global namespace with the C++ using namespace directive. In this case, you do not need to use the CDO namespace prefix. However, conflicts may arise if other types exist with these names. For example, MAPI defines a type called IMessage that will conflict with the CDO IMessage interface. In such cases, use the CDO namespace explicitly.
#include "cdosys.h" #include "cdosys_i.c" #include "cdosysstr.h" #include "cdosyserr.h" using namespace CDO; 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(); }