Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 12

Under-the-Hood Information About COM Components

IUnknown and IDispatch are object model interfaces, such as those discussed earlier in the section titled "Using Interfaces to Implement Polymorphism." As a VB programmer, however, you typically never need to know about IUnknown or IDispatch, which are provided automatically with every COM component. These interfaces are implemented internally and automatically by VB for every class object that you create in VB.

The purpose of IUnknown is to keep track of open references to an object and to provide the caller with the functionality that the object supports. IUnknown has three methods.

  • AddRef : This method increments an internal reference counter every time a client creates a new reference to an object.

  • Release : This method decrements the internal reference counter every time a client releases a reference to an object. When the counter reaches zero, the object can be destroyed.

  • QueryInterface : This method finds out whether an object supports a particular interface and, if it does, makes that interface's functions available to the calling application.

The purpose of IDispatch is to provide a standard way to access the members of a given interface for a particular object.

IDispatch has four methods.

  • GetTypeInfoCount : Returns a non-zero value if type information is available for this interface.

  • GetTypeInfo : Returns type information for the interface.

  • GetIDsOfNames : Finds the internal ID (known as the dispatch ID) of a particular property of method.

  • Invoke : Executes a method or accesses a property.

Vtable binding is a particular type of early binding that VB typically uses when you declare objects in client applications using the name of a registered object type.


  

<< Previous | Contents | Next (Chapter 13) >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved