Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

GETINTERFACE()

GETINTERFACE() allows early binding of COM objects, available beginning in VFP 7. Early binding is where VFP figures out the pointers to the COM object’s interface at compile time. Prior to VFP 7, objects could only be late bound, meaning that VFP figures out the pointers on every call. As you can guess, early binding generally gives a performance benefit.

In addition to providing an early-bound object reference (and providing design-time IntelliSense help, and runtime performance benefits), you can also access any interfaces that the COM object exposes.

Usage

oInterface = GETINTERFACE( oObject [ , cInterface
                          [ , cIdentifier ] ] )

Parameter

Value

Meaning

oObject

Object

The COM object.

cInterface

Omitted

Returns the early binding interface.

Character: GUID

The GUID of the COM object's interface to which you want a reference.

Character

The name of the interface, for example, "IEmployee".

cIdentifier

Character

A character string specifying either the name of the type library or the ProgID of the class.

oInterface

Object

The early-bound reference to the COM object, using the specified interface.

The oObject parameter needs to be a COM object. If it’s a regular VFP object, error 11 is raised. If you pass an invalid interface for cInterface, you’ll get the error 1426, “No such interface supported.”

For more information on early vs. late binding, see the Help topic, “Early (vtable) and Late (IDispatch) Binding.”

Example

* Assume a COM object called oMyObject is instantiated,
* and it has an interface called Icustomer.
oEarlyObject = GETINTERFACE(oMyObject, "ICustomer")

See Also

CreateObject(), CreateObjectEx()