Re: Attributes of IDL files
"adx" <adx@atnt.com> wrote in message
news:OBzS4gT3HHA.5316@TK2MSFTNGP04.phx.gbl
According to MSDN
(http://msdn2.microsoft.com/en-us/library/ms690150.aspx),
"The coclass statement defines an entirely new component class,
BkfstComponent, that includes two previously defined interfaces,
IFace1 and IFace2. The default attribute designates IFace1 as the
default interface."
1. What's "component class" here?
A set of interfaces identified by a CLSID. A COM client creates an
instance of such class (similarly to how you create an instance of a C++
class).
2. Why a "new component class" created?
That's the whole point of declaring one in an IDL file. Just like a C++
class declaration "creates" a new C++ class, where none existed before.
3. Then what component class in the example of the page is "old"?
The word "new" is not always contrasted to "old". If I tell you I've
just read a new book, will you ask me what happened to the old one?
4. Is it always necessary to declare one of the interfaces as
"default"?
No, but it doesn't hurt either. The only effect of this declaration I
can think of off the top of my head: VB allows one to use coclass name
as a synonym to that coclass' default interface's name.
5. What's the purpose or usage to have a default interface?
Not much. Some clients may use it to add some syntactic sugar. See VB
example above.
6. After reading the page about keyword "object" in the interface
header, for example,
[
object,
uuid(a03d1420-b1ec-11d0-8c3a-00c04fc31d2f),
]
it's still not very clear about its usage...
IDL files existed long before COM, to define RPC (remote procedure call)
interfaces. Microsoft adopted IDL syntax to also define COM interfaces.
[object] attribute identifies what follows as a COM interface, as
opposed to RPC interface.
--
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