Partilhar via


LanguageService.GetSite(Guid, IntPtr) Method

Definition

Returns an unmarshaled pointer to a requested interface.

public:
 virtual void GetSite(Guid % iid, [Runtime::InteropServices::Out] IntPtr % ptr);
public void GetSite (ref Guid iid, out IntPtr ptr);
abstract member GetSite : Guid * nativeint -> unit
override this.GetSite : Guid * nativeint -> unit
Public Sub GetSite (ByRef iid As Guid, ByRef ptr As IntPtr)

Parameters

iid
Guid

[in] The GUID of the desired interface.

ptr
IntPtr

nativeint

[out] Returns an unmarshaled interface pointer or a null value if the interface is not available.

Implements

Examples

This example shows how to get a pointer to an interface and marshal the pointer into an actual interface object.

IVsLanguageService GetLanguageService()  
{  
    IVsLanguageService pLanguageService = null;  
    IntPtr ptr = IntPtr.Zero;  
    GetSite(typeof(IVsLanguageService),ptr);  
    if (ptr != IntPtr.Zero)  
    {  
        pLanguageService = (IVsLanguageService)Marshal.GetObjectForIUnknown(ptr);  
    }  
    return pLanguageService;  

}

Remarks

This method queries the site (also known as a service provider) for the specified interface and returns a pointer to that interface. This method is an implementation of <xref:Microsoft.VisualStudio.Shell.ServiceProvider.Microsoft.VisualStudio.OLE.Interop.IObjectWithSite.GetSite%2A?displayProperty=fullName>.

Applies to