Compartir a través de


GetInterface Method

GetInterface Method

The GetInterface method returns the specified dual interface on the object.

Syntax

Function GetInterface(ByVal Interface as String) as Object
HRESULT GetInterface(BSTR Interface, IDispatch** pVal);

Parameters

Syntax

        Interface
      

The name of interface to obtain. The list of possible interfaces to return depends upon the COM class that provides the implementation.

Remarks

The GetInterface method is primarily intended as a generic interface navigation aid to use with scripting languages that do not support such navigation directly. Most COM classes that provide implementations of the IMessage interface expose additional dual interfaces that are accessible by scripting languages only through properties on the interface, such as BodyPart and DataSource, or through using the GetInterface method. When properties do not exist on the interface to return these interfaces, the GetInterface method must be used.

The list of valid interface names to pass to the GetInterface method depends on a specific implementation. As a general rule, the name of the interface that you want should match the physical name of the interface as it appears in the type library or .idl file. Check the appropriate COM class for a list of exposed dual interfaces. If the object does not support the requested interface, an exception is raised with the HRESULT value of E_INVALIDARG.

Example

VBScript

' assume iBodyPart contains a valid IBodyPart interface reference
Dim iMessage
Set iMessage = iBodyPart.GetInterface("IMessage")
...

Microsoft® JScript®

' assume iBodyPart contains a valid IBodyPart interface reference
var iMsg
iMsg = iBodyPart.GetInterface("IMessage");
...