Using the Automation Object Wizard

From RAD Studio
Jump to: navigation, search

Go Up to Creating Simple COM Servers Index

The Automation object wizard performs the following tasks:

  • Creates a new unit.
  • Defines a new class that descends from TAutoObject and sets up the class factory constructor. For more information on the base class, see Code generated by wizards.
  • Adds a type library to your project and adds your object and its interface to the type library.

Before you create an Automation object, create or open the project for an application containing functionality that you want to expose. The project can be either an application or ActiveX library, depending on your needs.

To display the Automation wizard:

  1. Choose File > New > Other to open the New Items dialog box.
  2. Select the folder labeled ActiveX under Delphi Projects.
  3. Double-click the Automation Object icon in the right pane.
  4. In the wizard dialog, specify the following:
  • CoClass name: This is the name of the object as it appears to clients. Your object's default interface is created with a name based on this CoClass name with an 'I' prepended, and the class created to implement your object has this name with a 'T' prepended.
  • Instancing: Unless you are creating an in-process server, you need to indicate how COM launches the application that houses your COM object. If your application implements more than one COM object, you should specify the same instancing for all of them.
  • Threading Model: Typically, client requests to your object enter on different threads of execution. You can specify how COM serializes these threads when it calls your object. Your choice of threading model determines how the object is registered. You are responsible for providing any threading support implied by the model you choose. For information on how to provide thread support to your application, see Writing multi-threaded applications
  • Generate Event support code: You must indicate whether you want your object to generate events to which clients can respond. The wizard can provide support for the interfaces required to generate events and the dispatching of calls to client event handlers.

The Automation object implements a dual interface, which supports both early (compile-time) binding through the VTable and late (runtime) binding through the IDispatch interface.

See Also