System.Win.ComObj.CoInitFlags

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

CoInitFlags: Integer = -1;  // defaults to no threading model, call CoInitialize()

C++

extern DELPHI_PACKAGE int CoInitFlags;

Properties

Type Visibility Source Unit Parent
variable public
System.Win.ComObj.pas
System.Win.ComObj.hpp
System.Win.ComObj System.Win.ComObj

Description

Specifies the level of threading support requested for a COM server .EXE.

CoInitFlags controls the way COM is initialized for threading support for non- VCL applications. This variable only affects executables (.EXEs), not in-process servers (.DLLs and .OCXs).

Typically, the wizard that creates the COM objects automatically adds code to initialize the level of threading support in your application. In applications containing multiple COM objects, COM is initialized for the highest level of support, where single threading is lowest and free threading is highest. To manually set the level of COM threading support, assign a value to CoInitFlags in the program's main source file before the call to Application.Initialize.

The following table lists the constants (defined in the ActiveX unit) that can be ordered together to create a value for CoInitFlags.


Constant Value Meaning

COINIT_MULTITHREADED

0

COM calls objects on any thread (free threading)

COINIT_APARTMENTTHREADED

2

Each object has its own thread (apartment model)

COINIT_DISABLE_OLE1DDE

4

Don't use DDE for Ole1 support.

COINIT_SPEED_OVER_MEMORY

8

Optimize for speed rather than memory.


The value of CoInitFlags is –1 for single threading.

Warning: As VCL applications always run on the STA, CoInitFlags cannot change their behavior. Please don't use this flag for a VCL application.

See Also