Compartilhar 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 (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)

Syntax

'Declaration
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
)
public:
virtual int QueryService(
    Guid% guidService, 
    Guid% iid, 
    [OutAttribute] IntPtr% obj
)
abstract QueryService : 
        guidService:Guid byref * 
        iid:Guid byref * 
        obj:IntPtr byref -> int  
override QueryService : 
        guidService:Guid byref * 
        iid:Guid byref * 
        obj:IntPtr byref -> int
public function QueryService(
    guidService : Guid, 
    iid : Guid, 
    obj : IntPtr
) : int

Parameters

  • guidService
    Type: Guid%

    [in] The GUID of the service to query.

  • iid
    Type: Guid%

    [in] The GUID of the desired interface.

  • obj
    Type: IntPtr%

    [out] An unmarshaled pointer to the interface.

Return Value

Type: 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