Re: Interface Question
- From: "Bjørge" <bjorge@xxxxxxx>
- Date: Mon, 9 Oct 2006 11:50:01 +0200
alanglloyd@xxxxxxx wrote:
Inheritance for IShellLink, IPersist, and IPersistFile is declared as
...
IShellLink = interfac(IUnknown) etc etc
IPersist = interface(IUnknown) etc etc
IPersistFile = interface(IPersist) etc etc
and I then see code of ...
var
ObjectIF : IUnknown;
ShellLinkIF : IShellLink;
PersistFileIF : IPersistFile;
begin
ObjectIf := CreateComObject(CLSID_Shellink);
ShellLinkIF := ObjectIF as IShellLink;
// do something with ShellLinkIF
PersistFileIF := ObjectIF as IPersistFile;
// do something with PersistFileIF
Now IShellLink has _none_ of the methods of IPersist or IPersistFile,
so _how_ can an IShellLink be typecast to an IPersistFile. Or is the
COM object of ObjectIF somehow re-created as an IPersistFile when
type-cast as such.
Hi !
The expression "ObjectIF as IPersistFile" is implemented through the
implementing class of ObjectIf's QueryInterface method. That's the "as"
operator when used on IUnknowns.
It's confusing. I know. (Maybe I too got it all wrong now ?)
--
Bjørge
'93 TDM850
bjorge@xxxxxxxxxxxx
.
- References:
- Interface Question
- From: alanglloyd@xxxxxxx
- Interface Question
- Prev by Date: Interface Question
- Next by Date: Re: Interface Question
- Previous by thread: Interface Question
- Next by thread: Re: Interface Question
- Index(es):
Relevant Pages
|