Compartir a través de


LanguageService.QueryService(Guid, Guid, IntPtr) Method

Definition

Returns the request interface from the specified service.

public:
 virtual int QueryService(Guid % guidService, Guid % iid, [Runtime::InteropServices::Out] IntPtr % obj);
public virtual int QueryService (ref Guid guidService, ref Guid iid, out IntPtr obj);
abstract member QueryService : Guid * Guid * nativeint -> int
override this.QueryService : Guid * Guid * nativeint -> int
Public Overridable Function QueryService (ByRef guidService As Guid, ByRef iid As Guid, ByRef obj As IntPtr) As Integer

Parameters

guidService
Guid

[in] The GUID of the service to query.

iid
Guid

[in] The GUID of the desired interface.

obj
IntPtr

nativeint

[out] An unmarshaled pointer to the interface.

Returns

If successful, returns S_OK; otherwise, returns an error code.

Implements

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;  

}

Remarks

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

Applies to