LanguageService.QueryService Method

Returns the request interface from the specified service.

Namespace:  Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

Syntax

'Declaration
Public Overridable Function QueryService ( _
    ByRef guidService As Guid, _
    ByRef iid As Guid, _
    <OutAttribute> ByRef obj As IntPtr _
) As Integer
'Usage
Dim instance As LanguageService 
Dim guidService As Guid 
Dim iid As Guid 
Dim obj As IntPtr 
Dim returnValue As Integer 

returnValue = instance.QueryService(guidService, _
    iid, obj)
public virtual int QueryService(
    ref Guid guidService,
    ref Guid iid,
    out IntPtr obj
)
public:
virtual int QueryService(
    Guid% guidService, 
    Guid% iid, 
    [OutAttribute] IntPtr% obj
)
public function QueryService(
    guidService : Guid, 
    iid : Guid, 
    obj : IntPtr
) : int

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

LanguageService Members

Microsoft.VisualStudio.Package Namespace