Export (0) Print
Expand All

ACDUAL: Adds Dual Interfaces to an Automation Application

Visual Studio 6.0
http://msdn.microsoft.com/en-us/library/4h56szat(v=vs.60) http://msdn.microsoft.com/en-us/library/4h56szat(v=vs.60) http://msdn.microsoft.com/en-us/library/ms221251(v=vs.60) http://msdn.microsoft.com/en-us/library/ms686592(v=vs.60) http://msdn.microsoft.com/en-us/library/ms221172(v=vs.60) http://msdn.microsoft.com/en-us/library/ms221048(v=vs.60)

ACDUAL demonstrates how to add dual-interface support to an MFC-based Automation (formerly OLE Automation) application. The sample consists of the following subdirectories:

  • MFCCTRL, which contains a version of the AUTODRIV sample that lets you select whether to control the server application using the dispatch interface or using vtable binding.

  • SERVER, which contains a version of the AUTOCLIK sample with dual-interface support.

  • VBCTRL, which contains a Visual Basic 4.0 program that controls the server application.

The ACDUAL server uses AUTOCLIK, Step 3 as a starting point. New GUIDs (globally unique identifiers) were generated to prevent confusion with the original AUTOCLIK sample, and some resources strings were changed to clarify whether the ACDUAL server is running. All other changes to the sources are marked with comment blocks like this:

      ... modified code goes here

For more information about dual interfaces, object description language (ODL) scripts, and Automation error interfaces, see .

Running the Sample

You must run ACDUAL as a stand-alone application once to register its ActiveX type with the system. After this is done, you are ready to run either the VB or MFC version of AUTODRIV. Both versions of AUTODRIV launch ACDUAL and create a Document object, which you can then manipulate using Automation via the AUTODRIV user interface. The MFC version of AUTODRIV contains an additional check box that lets you select whether to use VTBL binding to communicate with the ACDUAL Document object.

Dual Interfaces

A dual interface allows you to implement an IDispatch interface or a VTBL interface. A dual interface is strongly recommended for all exposed Automation objects. Issues to consider when implementing a dual interface are discussed in and include:

  • Implementing dual-interface support for CCmdTarget-based classes

  • Passing dual-interface pointers

  • Enabling typesafe binding, including:
    • Registering the application's library type

    • Modifying project build settings to accommodate type library changes

    • Specifying the correct object class name in a type library
  • Handling exceptions and the automation error interface

See also the ActiveX topics , , , and the ODL reference entry on the attribute.

© 2014 Microsoft