Re: Initializing COM library
"anony" <rajayyala@gmail.com> wrote in message
news:d8511491-c20a-4ac7-b24a-c1a6dd316162@2g2000hsn.googlegroups.com
Ok..this is what I do:
I created an ATL project. Then i added a couple of classes ( AtlSimple
objects ). Within each class ( AtlSimple object ), I make this call:
anotherObjectSmartPointer.CreateInstance(CLSID_AnotherObject);
("AnotherObject" is a COM object)
Now, I never had any CoInitialize[Ex] calls in my code before. It
never gave me that particualr error. I ran this application on XP as
well as W2K3. No problems.
As far as I can tell, you don't create any new threads yet. You are
calling CreateInstance on the same thread your object is created on,
which, like I said, must have already initialized COM (or your object
couldn't be called on it in the first place).
Then, to take care of some painting issues, I spun a thread in each of
these objects ( since each one of the AtlSimple objects is independent
but exist in the same ATL project, let us take only one class for our
consideration )
So, even after I introduced the thread, I did not have any issues
either on my Development machine ( XP ) or on our QA machine ( W2k3 ).
What does this thread do? Does it do anything COM related? If so, what?
Since you mention painting, be aware that GDI is not thread-safe. If you
have a window created by one thread, you can't paint on it from another
thread. This is unrelated to COM.
--
With best wishes,
Igor Tandetnik
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