SContainerDispatch Interface
Passed to the QueryService method to return a reference to the IDispatch Interface [Automation].
Namespace: Microsoft.VisualStudio.OLE.Interop
Assembly: Microsoft.VisualStudio.Shell.Interop.8.0 (in Microsoft.VisualStudio.Shell.Interop.8.0.dll)
Syntax
'Declaração
<GuidAttribute("B722BE00-4E68-101B-A2BC-00AA00404770")> _
Public Interface SContainerDispatch
[GuidAttribute("B722BE00-4E68-101B-A2BC-00AA00404770")]
public interface SContainerDispatch
Remarks
The IDispatch Interface [Automation] is implemented on any control or VSPackage that supports automation. However, to obtain the IDispatch interface, it is necessary to query the control or VSPackage for a service provider and ask that service provider to obtain the IDispatch interface from the SContainerDispatch service. See the example for how this can be accomplished.
Examples
This example shows how to obtain the IDispatch Interface [Automation] from the SContainerDispatch service.
IDispatch GetDispatchInterface(object pUnknown)
{
IDispatch pDispatchInterface = null;
if (null != pUnknown)
{
Microsoft.VisualStudio.OLE.Interop.IServiceProvider pServiceProvider;
pServiceProvider = pUnknown as Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
if (null != pServiceProvider)
{
Guid serviceGuid = typeof(SContainerDispatch).GUID;
Guid interfaceGuid = typeof(IDispatch).GUID;
IntPtr pInterface = IntPtr.Zero;
int hr = pServiceProvider.QueryService(ref serviceGuid,
ref interfaceGuid,
out pInterface);
if (Microsoft.VisualStudio.ErrorHandler.Succeeded(hr))
{
pDispatchInterface = Marshal.GetObjectForIUnknown(pInterface)
as IDispatch;
}
}
}
return pDispatchInterface;
}