Re: Interface Question



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


.



Relevant Pages

  • Re: Interface Question
    ... ShellLinkIF: IShellLink; ... PersistFileIF: IPersistFile; ... ShellLinkIF:= ObjectIF as IShellLink; ... you're given a pointer to a pointer to a list of functions. ...
    (comp.lang.pascal.delphi.misc)
  • Interface Question
    ... Inheritance for IShellLink, IPersist, and IPersistFile is declared as ... PersistFileIF: IPersistFile; ... ShellLinkIF:= ObjectIF as IShellLink; ...
    (comp.lang.pascal.delphi.misc)
  • A question about IShellLink interface and the COM object.
    ... We can query the object implementing IShellLink for IPersistFile to ... create a shortcut file. ...
    (microsoft.public.vc.language)