Share via


IDebugDocumentContext2::GetLanguageInfo

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Gets the language associated with this document context.

Syntax

HRESULT GetLanguageInfo(
    BSTR* pbstrLanguage,
    GUID* pguidLanguage
);
int GetLanguageInfo(
    out string pbstrLanguage,
    out Guid   pguidLanguage
);

Parameters

pbstrLanguage
[out] Returns the name of the language that implements the code at this document context.

pguidLanguage
[out] Returns the GUID of the language that implements the code at this document context. For example, guidVBScriptLang or guidCPPLang. This GUID is not limited to the languages supplied by Visual Studio.

Return Value

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

Example

The following example shows how to implement this method for a simple CDebugContext object that exposes the IDebugDocumentContext2 interface.

HRESULT CDebugContext::GetLanguageInfo(BSTR* pbstrLanguage, GUID* pguidLanguage)
{
    HRESULT hr;

    // Check for a valid language argument pointers.
    if (pbstrLanguage && pguidLanguage)
    {
        *pguidLanguage = GUID_NULL;
        *pbstrLanguage = SysAllocString(L"Batch File");
        if (*pbstrLanguage)
        {
            *pguidLanguage = guidBatLang;
            hr = S_OK;
        }
        else
        {
            hr = E_OUTOFMEMORY;
        }
    }
    else
    {
        hr = E_INVALIDARG;
    }

    return hr;
}

See also