Re: Initializing COM library
"anony" <email@example.com> wrote in message
1) Prior to this, I didnt have any CoInitialize() calls anywhere in my
project. I do understand that we need to have a CoInitialize() call
per thread. But, before I introduced threads, what calls does ATL make
to initialize the COM library? I havent seen any CoInitialize() calls
ATL doesn't - the client that hosts your objects does. The client has to
create your object with CoCreateInstance - but CoCreateInstance fails
until the client calls CoInitialize[Ex] first.
So by the time a COM object is created, the caller must have necessarily
initialized COM already. The COM object only needs to initialize COM on
new threads it explicitly creates.
2) Even after introducing the threads it works great on all our
machines ( i.e at my work place ) without the CoInitialize() calls. I
do understand that "it works doesnt mean it's right". I am just
curious why it's working on some machines and doesnt work on other
Are you running the same hosting application the customer is running? It
might not have anything to do with different machines, but with
different ways the object is used. It's hard to tell without knowing
Are you, by any chance, running Win2K while the customer runs XP and up?
I seem to remember in Win2K and below a thread automatically joined MTA
on first COM call if COM wasn't explicitly initialized.
With best wishes,
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925