Using COM in an arbitrary thread

  apartments, com, multithreading, windows

Suppose I have a COM object created on an MTA thread (i.e., initialized with CoInitializeEx(NULL, COINIT_MULTITHREADED)). I would like to use said object from some other, arbitrary, thread. For instance, from the thread pool.
Since I don’t own this thread, I cannot call CoInitializeEx on it, so technically I cannot use COM.

I’ve seen other questions here (like this one) dealing with a similar issue in .NET, but I’m interested in native threads / thread pools, not managed ones.

Is it at all possible to use the object from an arbitrary thread? How?

Source: Windows Questions

LEAVE A COMMENT