Re: Default Implementation for IUnknown
A CLSID for non-creatable object is mostly useful if you expose
it in the type library via [noncreatable]. This is to allow VB6
clients to sink events from such internal object. It's also needed
if you expose rich error information via IErrorInfo. Otherwise
you can omit CComCoClass in your base class list and thus
won't need a CLSID.
Note that using CComObject<> to explictly instantiate your
class does not use a class object regardless if you are deriving
from CComCoclass or not. As I already showed you - you
should not try to instantiate the object directly - use the
CreateInstance method for that purpose as I showed you
in my earlier post. The reason for this is that in addition to
CreateInstance trapping any constructor exceptions and
converting them to a handy HRESULT (and preferably you
shouldn't be using exceptions in the first place when developing
with ATL), it also takes care of calling your FinalConstruct
method thus finishing your object's initialization.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Stefan Weber" <stefan.weber@gmail.com> wrote in message
news:1178522443.462644.224510@w5g2000hsg.googlegroups.com...
No, your class does not implement IUnknown. CComObject<>
works by deriving from your class and providing implementation
for the 3 IUnknown methods thus populating the vtables of all
COM interfaces implemented by your class. The rest of your
speculations are meaningless in this new light.
Hmm, I think I understand now :) Thanks a lot for all the interesting
answers!
Now, I need to actually implement it. Obviously, I'm implementing a
coclass here and wonder. I read that every coclass needs a GUID. In my
case, this is not necessary as it will only be used internally. Can I
leave out the GUID in such a case?
Also, is it legal to instantiate the object with it's constructor
directly, or do I need to use the class factory?
Thanks, I really appreciate your help!
Stefan