Compartir a través de


IDiaInjectedSource

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

Accesses injected source code stored in the DIA data source.

Syntax

IDiaInjectedSource : IUnknown

Methods in Vtable Order

The following table shows the methods of IDiaInjectedSource.

Method Description
IDiaInjectedSource::get_crc Retrieves a cyclic redundancy check (CRC) calculated from the bytes of the source code.
IDiaInjectedSource::get_length Retrieves the number of bytes of code.
IDiaInjectedSource::get_filename Retrieves the file name for the source.
IDiaInjectedSource::get_objectFilename Retrieves the object file name to which the source was compiled.
IDiaInjectedSource::get_virtualFilename Retrieves the name given to non-file source code; that is, code that was injected.
IDiaInjectedSource::get_sourceCompression Retrieves the indicator of the source compression used.
IDiaInjectedSource::get_source Retrieves the source code bytes.

Remarks

Injected source is text that is injected during compilation. This does not mean the preprocessor #include used in C++.

Notes for Callers

Obtain this interface by calling the IDiaEnumInjectedSources::Item or IDiaEnumInjectedSources::Next methods. See the IDiaEnumInjectedSources interface for an example of obtaining the IDiaInjectedSource interface.

Example

This example displays the data available from the IDiaInjectedSource interface. For an alternative approach using the IDiaPropertyStorage interface, see the example in the IDiaEnumInjectedSources interface.

void PrintInjectedSource(IDiaInjectedSource* pSource)
{
    ULONGLONG codeLength      = 0;
    DWORD     crc             = 0;
    DWORD     compressionType = 0;
    BSTR      sourceFilename  = NULL;
    BSTR      objectFilename  = NULL;
    BSTR      virtualFilename = NULL;

    std::cout << "Injected Source:" << std::endl;
    if (pSource != NULL)
    {
        if (pSource->get_crc(&crc) == S_OK &&
            pSource->get_sourceCompression(&compressionType) == S_OK &&
            pSource->get_length(&codeLength) == S_OK)
        {
            wprintf(L"  crc = %lu\n", crc);
            wprintf(L"  code length = %I64u\n",codeLength);
            wprintf(L"  compression type code = %lu\n", compressionType);
        }

        wprintf(L"  source filename: ");
        if (pSource->get_filename(&sourceFilename) == S_OK)
        {
            wprintf(L"%s", sourceFilename);
        }
        else
        {
            wprintf(L"<none>");
        }
        wprintf(L"\n");

        wprintf(L"  object filename: ");
        if (pSource->get_filename(&objectFilename) == S_OK)
        {
            wprintf(L"%s", objectFilename);
        }
        else
        {
            wprintf(L"<none>");
        }
        wprintf(L"\n");

        wprintf(L"  virtual filename: ");
        if (pSource->get_filename(&virtualFilename) == S_OK)
        {
            wprintf(L"%s", virtualFilename);
        }
        else
        {
            wprintf(L"<none>");
        }
        wprintf(L"\n");

        SysFreeString(sourceFilename);
        SysFreeString(objectFilename);
        SysFreeString(virtualFilename);
    }
}

Requirements

Header: Dia2.h

Library: diaguids.lib

DLL: msdia80.dll

See also