IUnknown.QueryInterface

From Xojo Documentation

Method

IUnknown.QueryInterface(riid As Ptr, ByRef out As Ptr) As Integer

Supported for all project types and targets.

Retrieves the address of a specified interface.

Examples

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

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

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

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