Platform SDK: CDO for Windows 2000 |
The GetInterface method returns the specified dual interface on the object.
[Visual Basic] Function GetInterface(ByVal Interface as String) as Object [C++] HRESULT GetInterface(BSTR Interface, IDispatch** pVal); [IDL] HRESULT GetInterface([in] BSTR Interface, [out,retval] IDispatch** pVal);
The GetInterface method is primarily intended as a generic interface navigation aid to scripting languages that do not support such navigation directly. Most Component Object Model (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 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 is dependent on a specific implementation. As a general rule, the name of the desired interface 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.
The following example in VBScript and Microsoft® Jscript® demonstrates how to use the GetInterface method to return other interfaces on a Message object.
VBScript
Dim iMsg ' Get the IMessage interface (Dispatch) Set iMsg = CreateObject("CDO.Message") ' Get the IDataSource on the Message Object (IDispatch) Set iDSrc = iMsg.GetInterface("IDataSource") ' Get the IBodyPart interface on the Message Object (IDispatch) Set iBp = iMsg.GetInterface("IBodyPart")
JScript
var iMsg = new ActiveXObject("CDO.Message"); var iDsrc = iMsg.GetInterface("IDataSource"); var iBp = iMsg.GetInterface("IBodyPart");