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.

COMClassInfo()

This function returns information on OLE or COM classes.

Usage

cRetVal = COMClassInfo( oObject [ , nInfoType ] )

Parameter

Value

Meaning

oObject

Object

The object to report on.

nInfoType

Omitted or 1

Return the object's ProgID.

2

Return the object's VersionIndependentProgID.

3

Return the object's friendly name.

4

Return the object's CLSID.

5

Return the type of object, as follows:

1—Native VFP object
2—ActiveX control
3—COM server object
4—OLEBound object
5—Other

cRetVal

Character

The value requested above.

Empty string

The object specified was not a COM or OLE object.

This function lets you explore some of the properties of a COM object handed to you. We expect to use this function mainly in black-box routines that need to work with what they are passed.

Starting in VFP 7, you can find out what kind of object you’re dealing with by passing 5 for the nInfoType parameter. In that case, the function handles native VFP objects, as well as COM objects. Help shows only four return values for object type, and that’s all we’ve been able to turn up. However, when you highlight 5 in the list of values that IntelliSense provides for the second parameter, you see a list of return values. That list includes “5 – Other.” (Actually, even the existence of that list is something of an anomaly. We can’t think of any other function where the list of values shows you the possible return values.)

Example

oGraph = CREATEOBJECT("MSGraph.Application")
* Determine which version is installed:
? COMClassInfo(oGraph,1)  && "MSGraph.Application.8"
* Grab the friendly name, perhaps to use as a caption.
lcCaption = COMClassInfo(oGraph,3)
? lcCaption  && "Microsoft Graph 2000 Application"

See Also

VarType()