Automation provides interfaces for accessing exposed objects from an application or programming tool written in C or C++. The following sections show C++ code that uses the same type of access method as the Visual Basic code, which is described earlier in this chapter. Although the process is more complex with C++ than with Visual Basic, the approach is similar. This section shows the minimum code necessary to access and manipulate a remote object.
You can use the IDispatch interface to access ActiveX objects, or you can access objects directly through the VTBL. Because VTBL references can be bound at compile time, VTBL access is generally faster than through IDispatch. Whenever possible, use the ITypeInfo or ITypeInfo2 interfaces to get information about an object, including the VTBL addresses of the object's members. Then, use this information to access ActiveX objects through the VTBL.
To create compilers and other programming tools that use information from type libraries, use the ITypeComp interface. This interface binds to exposed objects at compile time. For details on ITypeComp, see Chapter 9, "Type Description Interfaces."