O'Reilly logo

VB Shell Programming by J.P. Hamilton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Icon Handler Interfaces

Now that you know how an icon handler works, let’s discuss the interfaces involved in a little more detail.

IPersistFile

IPersistFile inherits one method, GetClassID, from IPersist. IPer-sistFile contains an additional five methods (see Table 5.1): IsDirty, Load, Save, SaveCompleted, and GetCurFile. Typically, IPersistFile is implemented when you want to read or write information from a file. There are many more scenarios. You are encouraged to learn more about this interface, because in the world of COM, this interface gets some major game time. In our case, however, we are only interested in one method, and that’s Load.

We do have a small problem with IPersistFile. It’s derived from IPersist, and VB does not like interfaces that are derived from anything other than IUnknown or IDispatch. This is because Microsoft believes that Visual Basic objects should always support late binding and, hence, should always be derived from IDispatch. So what do we do? Before addressing this question, let’s look at the IDL in Example 5.1, which shows that IPersistFile is derived from IPersist. IPersistFile has inherited the IPersist method GetClassID.

Example 5-1. VB Will Not Accept This Definition of IPersistFile

[ uuid(0000010c-0000-0000-C000-000000000046), helpstring("IPersist Interface"), odl ] interface IPersist : IUnknown { HRESULT GetClassID([in, out] CLSID *lpClassID); } [ uuid(0000010b-0000-0000-C000-000000000046), helpstring("IPersistFile Interface"), odl ] interface ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required