This documentation is archived and is not being maintained.

ACDUAL Sample: Adds Dual Interfaces to an Automation Application (C++ Samples) 

Download sample

ACDUAL demonstrates how to add dual-interface support to an MFC-based Automation application with the native compiler COM support. See the MFC ACDUAL sample for more information.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

Building and Running the Sample

NoteNote

If you are running Visual C++ Express Edition, you might need to install the Platform SDK before running this sample. For information on how to do this, see How to: Use Visual C++ Express Edition with the Microsoft Platform SDK.

To build and run this sample

  1. Open the solution acdual.sln.

  2. On the Build menu, click Build Solution.

  3. Set acdual as the startup project (right-click the project node and click Set as StartUp Project) and click the Start button. Acdual will register itself (otherwise the client project couldn't run). Close the acdual application before continuing.

  4. Set autodriv as the startup project and run it. Use the AutoClik Test Drive dialog box to modify the output in the ACDual AClick window.

Comparison with the MFC Version

The differences between this sample and the MFC sample with the same name are:

  • The COleDispatchDriver class is no longer necessary. Instead, #import is used to import a type library.

  • The _bstr_t and _variant_t wrapper classes are used to simplify operations of BSTR and VARIANT types.

  • __declspec(property) is used to simplify assignment operations for properties of COM objects.

  • COM error handling is now performed by using the _com_error class.

With the Visual C++ native compiler COM support, the resulting sample code is shorter and more efficient. The MFC-based ACDUAL sample uses both dual interfaces and dispinterfaces only. Compare this sample with the MFC version to see the differences in source code.

Keywords

This sample demonstrates the following keywords:

dispinterface; #import; _com_ptr_t; _variant_t; _bstr_t; _com_error

See Also

Show: