LanguageService.QueryService Method (Guid, Guid, IntPtr)


Returns the request interface from the specified service.

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

public virtual int QueryService(
	ref Guid guidService,
	ref Guid iid,
	out IntPtr obj


Type: System.Guid

[in] The GUID of the service to query.

Type: System.Guid

[in] The GUID of the desired interface.

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.

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.

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;
    if (ptr != IntPtr.Zero)
        pUIShell = (IVsUIShell)Marshal.GetObjectForIUnknown(ptr);
    return pUIShell;


Return to top