Re: Checking the existence of a method in an Interface
"Vi2" <sharachov@hotmail.com> wrote in message
news:f0b3b250-34fd-4fee-baad-6ddeccf5ac5a@r66g2000hsg.googlegroups.com
To Anatoly and Igor: Look at type library of any MS product (Word,
Excel etc), and you will see "violation of the fundamental
principles". ;)
Do you have an example where an interface has changed under the same
IID? Which versions of which type libraries describe two interfaces with
the same IID but different sets of methods?
Note that it's not illegal to modify a dispinterface, but it is illegal
to modify a "regular" interface. A regular interface is a contract on
vtable layout: a missing method leads to a crash, and there's no way to
recover gracefully. A dispinterface is a contract on the supported set
and meaning of DISPIDs: a missing "method" simply results in
IDispatch::Invoke returning DISP_E_MEMBERNOTFOUND error.
Witness IHTMLDocument{2, 3, 4, 5}: a new dual interface is defined every
time new methods need to be added. The IDispatch portion of each of
these interfaces actually supports methods of all of them. In fact, the
same object that implements IHTMLDocument? also implements
DispHTMLDocument - the pure dispinterface that supports all methods, and
is expanded with each IE version. This is the interface scripts work
with.
--
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