Board index » cppbuilder » Syntax for using TInitOleT (using DCOM in thread)

Syntax for using TInitOleT (using DCOM in thread)

I want to use a dcom control in a thread ... and I got the error COInitilize
not executed.   In the help
file I found the information below.   No matter what I try to code, I get a
syntax error.   Could someone
please give me an example which will work.

thanks in advance
doug

from the help file.......
__________________________________________________________________________
Initializes COM and specifies a threading model.

typedef enum tagCOINIT{

  COINIT_APARTMENTTHREADED = 0x2, // Apartment model
  COINIT_MULTITHREADED = 0x0, // COM calls objects on any thread.
  COINIT_DISABLE_OLE1DDE = 0x4, // Don't use DDE for Ole1 support.
  COINIT_SPEED_OVER_MEMORY = 0x8, // Trade memory for speed.

Quote
} COINIT;

TInitOleT(COINIT initFlag = m_DefaultInitFlag);

Description

The TInitOleT constructor calls CoInitialize or CoInitializeEx to initialize
the COM library for use by the calling thread. It calls CoInitialize
whenever possible, because the CoInitializeEx is not available on all 32-bit
versions of Windows.

The initFlag parameter indicates the threading model that COM should enforce
when making interface calls. Any combination of values from the COINIT
enumeration can be used, except that the COINIT_APARTMENTTHREADED and
COINIT_MULTITHREADED flags cannot both be set.

If the initFlag parameter is omitted, the threading model defaults to either
COINIT_APARTMENTTHREADED or COINIT_MULTITHREADED, depending on which model
is selected on the ATL page of the project options dialog.

 

Re:Syntax for using TInitOleT (using DCOM in thread)


Create an instance of TInotOle:

#include <utilcls.h>
...
TInitOle InitOle;

As long as the instance of TInitOle is in scope OLE will be initialized. Now
this does not work for multithreaded applications with threads that access
OLE. Within each thread you will need to make a call to CoInitializeEx and
forego TInitOle.

Chris

Quote
"Doulas Stites" <dlsti...@ix.netcom.com> wrote in message

news:3adc38e6_1@dnews...
Quote
> I want to use a dcom control in a thread ... and I got the error
COInitilize
> not executed.   In the help
> file I found the information below.   No matter what I try to code, I get
a
> syntax error.   Could someone
> please give me an example which will work.

> thanks in advance
> doug

> from the help file.......
> __________________________________________________________________________
> Initializes COM and specifies a threading model.

> typedef enum tagCOINIT{

>   COINIT_APARTMENTTHREADED = 0x2, // Apartment model
>   COINIT_MULTITHREADED = 0x0, // COM calls objects on any thread.
>   COINIT_DISABLE_OLE1DDE = 0x4, // Don't use DDE for Ole1 support.
>   COINIT_SPEED_OVER_MEMORY = 0x8, // Trade memory for speed.

> } COINIT;

> TInitOleT(COINIT initFlag = m_DefaultInitFlag);

> Description

> The TInitOleT constructor calls CoInitialize or CoInitializeEx to
initialize
> the COM library for use by the calling thread. It calls CoInitialize
> whenever possible, because the CoInitializeEx is not available on all
32-bit
> versions of Windows.

> The initFlag parameter indicates the threading model that COM should
enforce
> when making interface calls. Any combination of values from the COINIT
> enumeration can be used, except that the COINIT_APARTMENTTHREADED and
> COINIT_MULTITHREADED flags cannot both be set.

> If the initFlag parameter is omitted, the threading model defaults to
either
> COINIT_APARTMENTTHREADED or COINIT_MULTITHREADED, depending on which model
> is selected on the ATL page of the project options dialog.

Other Threads