IUnknown Interface

In addition to communicating with other components, a component must be able to create and destroy an object. All Microsoft COM components implement the creation and destruction of objects with the IUnknown interface. The IUnknown interface includes three functions.


Asks the component if it supports a particular interface. In VB this function is accessed by binding an object variable to a particular class:

Dim ObjectVariableName as [New] ClassName


Adds another reference to the tally (kept by the component) of how many clients are accessing it. In VB this function is accessed by setting an object variable as an instance of a class:

Set ObjectVariableName = [New] ClassName


Releases a reference to itself by clients. In VB this function is accessed by setting an object variable back to Nothing:

Set objInstance = Nothing


The binding of an object determines the speed at which the objects methods can be accessed. There are  three types of binding:

Late Bound

Aka weakly typed. This binding is slow. The syntax of this implementation is:

Dim ObjectVariableName As Object

Early DispID Bound

This is medium fast binding. The syntax of this implementation is:

Dim ObjectVariableName As ClassName

Early vtable Bound

Aka strongly typed). This is the fastest binding. This is usually used by languages like C.

Object Methods

You can also set objects of other programs, especially ActiveX component compliant programs, to object variables by using the following functions.


PathName indicates the path and file of the object. If PathName is omitted, then AppName.ObjectTypeOrClass is required to create a new object instance.

Dim obj As Object
Set obj1 = GetObject([PathName] [,AppName.ObjectTypeOrClass])
Set obj = GetObject("", "Excel.Application")
'Just like CreateObject on local machine.
Set obj = GetObject("C:\Foobar\text.xls")
'Points to an object in another directory


ServerName indicates where the object will be created. If ServerName is omitted, then the local machine will be used.

Dim obj As Object
Set obj = CreateObject(AppName.ObjectTypeOrClass, [ServerName])
Set obj = CreateObject("Excel.Application", "ServerA")
'Make a new object on ServerA
In ASP (Active Server Pages) the built-in Server object can be used to create other objects that are registered on that server.
Set obj = Server.CreateObject("progID")
<% Set objAd = Server.CreateObject("MSWC.AdRotator") %>
<% Set objDog = Server.CreateObject("GHCustom.Dog") %>

Page Modified: (Hand noted: ) (Auto noted: )