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.

Sys(3095), Sys(3096)

These functions, added in VFP 7, deal with IDispatch pointers for COM objects. SYS(3095) returns the pointer for a specified COM object, while SYS(3096) returns the object for a specified pointer.

Usage

nPointer = SYS( 3095, oCOMObject [, cInterface ] )
oComObject = SYS( 3096, nPointer )

Parameter

Value

Meaning

oCOMObject

Object

The COM object reference for which you want/have the IDispatch pointer.

cInterface

GUID

The GUID for the interface you want to use. (We think. This is not documented in Help, but is shown in the Accessibility Browser application.)

nPointer

Numeric

The IDispatch pointer.

This is really advanced stuff. In fact, the IntelliSense tooltips even say, “This is only for advanced developers.” We can see the use for SYS(3095), as we’ve run into API functions that require the use of IDispatch pointers. But we’ve never run into a situation where we have an IDispatch pointer and need to locate its object (however, until VFP 7, we’ve not been able to get an IDispatch pointer, never mind the fact that we’ve never dealt directly with IDispatch pointers in our careers to date).

The only example of these commands that we found turned up in Tools\MSAA\AccBrow.scx. And that’s where we found that SYS(3095) can use one more parameter than Help defines. Feel free to parse through the code; you’ll get a good feel for how to use the Active Accessibility features while you’re figuring out these SYS() Functions. We’re pretty certain that they’ve been added specifically to support MSAA, and the average developer won’t need to deal with them.

Example

* Instantiate a COM object.
oMyWord = CREATEOBJECT("Word.Application")
* Get a pointer to the IDispatch interface.
ptrIDispatch = SYS(3095, oMyWord)
* Display the pointer's value:
? ptrIdispatch
* Now that you've got the pointer, find the object.
oObjectFromIDispatch = SYS(3096, ptrIDispatch)
* Display the object's name; should say "Microsoft Word":
? oObjectFromIDispatch.Name

See Also

Sys(), Sys(3097), Sys(3098)