COM Object Instancing Types

From RAD Studio
Jump to: navigation, search

Go Up to Using the Automation Object Wizard


Many of the COM wizards require you to specify an instancing mode for the object. Instancing determines how many instances of your object clients can create in a single executable. If you specify a Single Instance model, for example, then once a client has instantiated your object, COM removes the application from view so that other clients must launch their own instances of the application. Because this affects the visibility of your application as a whole, the instancing mode must be consistent across all objects in your application that can be instantiated by clients. That is, you should not create one object in your application that uses Single Instance mode and another in the same application that uses Multiple Instance mode.

Note: Instancing is ignored when your COM object is used only as an in-process server.

When the wizard creates a new COM object, it can have any of the following instancing types:

Instancing Meaning

Internal

The object can only be created internally. An external application cannot create an instance of the object directly, although your application can create the object and pass an interface for it to clients.

Single Instance

Allows clients to create only a single instance of the object for each executable (application), so creating multiple instances results in launching multiple instances of the application. Each client has its own dedicated instance of the server application.

Multiple Instances

Specifies that multiple clients can create instances of the object in the same process space.