Partilhar via


LanguageService.QueryService Method

Returns the request interface from the specified service.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

Syntax

'Declaração
Public Overridable Function QueryService ( _
    ByRef guidService As Guid, _
    ByRef iid As Guid, _
    <OutAttribute> ByRef obj As IntPtr _
) As Integer
public virtual int QueryService(
    ref Guid guidService,
    ref Guid iid,
    out IntPtr obj
)

Parameters

  • guidService
    Type: System.Guid%
    [in] The GUID of the service to query.
  • iid
    Type: System.Guid%
    [in] The GUID of the desired interface.
  • obj
    Type: System.IntPtr%
    [out] An unmarshaled pointer to the interface.

Return Value

Type: System.Int32
If successful, returns S_OK; otherwise, returns an error code.

Implements

IServiceProvider.QueryService(Guid%, Guid%, IntPtr%)

Remarks

The base method calls LanguageService.GetService to obtain the IOleServiceProvider interface and passes the call on to its QueryService. This method is an implementation of QueryService.

Examples

This example shows how to use this method to query for an interface and marshal the resulting pointer into an actual interface object.

IVsUIShell GetUIShell(Microsoft.VisualStudio.OLE.Interop.IServiceProvider pProvider)
{
    IVsUIShell pUIShell = null;
    IntPtr ptr = IntPtr.Zero;
    pProvider.QueryService.(typeof(SVsUIShell).GUID,ptr);
    if (ptr != IntPtr.Zero)
    {
        pUIShell = (IVsUIShell)Marshal.GetObjectForIUnknown(ptr);
    }
    return pUIShell;

}

.NET Framework Security

See Also

Reference

LanguageService Class

Microsoft.VisualStudio.Package Namespace