IDispatch

From Xojo Documentation

Revision as of 16:45, 11 May 2012 by WYu (talk | contribs) (Initial documentation on COM.IDispatch)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Class (inherits from IUnknown)

IDispatch is the common interface exposed by automation servers (like Internet Explorer, Word, Excel, etc.). For automation servers that support dual interfaces you can use the OLEObject class to automate them.


Methods
GetIDofName Invoke


Examples

The following automates Internet Explorer and queries for a specific interface (each interface is identified by a unique IID)

Dim ie As New OLEObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate("google.com")

Dim unk As New COM.IUnknown(ie.Handle)

// Query for the IID_IWebBrowser2 interface
Dim iid As MemoryBlock = COM.IIDFromString("{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}")
Dim out As Ptr
If 0 = unk.QueryInterface(iid, out) Then
// Yay this interface exists
Break
End If

See Also

COM module; IDispatch, IEnumVARIANT, IPicture.