共用方式為


SContainerDispatch Interface

Definition

Passed to the QueryService(Guid, Guid, IntPtr) method to return a reference to the IDispatch Interface.

public interface class SContainerDispatch
public interface class SContainerDispatch
__interface SContainerDispatch
[System.Runtime.InteropServices.Guid("B722BE00-4E68-101B-A2BC-00AA00404770")]
public interface SContainerDispatch
[<System.Runtime.InteropServices.Guid("B722BE00-4E68-101B-A2BC-00AA00404770")>]
type SContainerDispatch = interface
Public Interface SContainerDispatch
Attributes

Examples

This example shows how to obtain the IDispatch Interfacefrom 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;  
}  

Remarks

TheIDispatch Interfaceis 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.

Applies to