IDiaEnumInjectedSources

枚举数据源中包含的各种注入源代码。

语法

IDiaEnumInjectedSources : IUnknown

Vtable 顺序中的方法

下表显示了 IDiaEnumInjectedSources 方法。

方法 说明
IDiaEnumInjectedSources::get__NewEnum 检索此枚举器的 IEnumVARIANT Interface 版本。
IDiaEnumInjectedSources::get_Count 检索注入源代码的数量。
IDiaEnumInjectedSources::Item 通过索引检索注入源代码。
IDiaEnumInjectedSources::Next 检索枚举序列中指定数量的注入源代码。
IDiaEnumInjectedSources::Skip 跳过枚举序列中指定数量的注入源代码。
IDiaEnumInjectedSources::Reset 将枚举序列重置到开头。
IDiaEnumInjectedSources::Clone 创建一个枚举器,其中包含与当前枚举器相同的枚举状态。

备注

对调用者的说明

通过调用具有特定源文件名称的 IDiaSession::findInjectedSource 方法或使用接口的全局唯一标识符(GUID)IDiaEnumInjectedSources调用 IDiaSession::getEnumTables 方法获取此接口。

示例

此示例演示如何获取(GetEnumInjectedSources 函数)和使用(DumpAllInjectedSources 函数)IDiaEnumInjectedSources 接口。 有关 PrintPropertyStorage 函数的实现,请参阅 IDiaPropertyStorage 接口。 有关备用输出,请参阅 IDiaInjectedSource 接口。


IDiaEnumInjectedSources* GetEnumInjectedSources(IDiaSession *pSession)
{
    IDiaEnumInjectedSources* pUnknown    = NULL;
    REFIID                   iid         = __uuidof(IDiaEnumInjectedSources);
    IDiaEnumTables*          pEnumTables = NULL;
    IDiaTable*               pTable      = NULL;
    ULONG                    celt        = 0;

    if (pSession->getEnumTables(&pEnumTables) != S_OK)
    {
        wprintf(L"ERROR - GetTable() getEnumTables\n");
        return NULL;
    }
    while (pEnumTables->Next(1, &pTable, &celt) == S_OK && celt == 1)
    {
        // There is only one table that matches the given iid
        HRESULT hr = pTable->QueryInterface(iid, (void**)&pUnknown);
        pTable->Release();
        if (hr == S_OK)
        {
            break;
        }
    }
    pEnumTables->Release();
    return pUnknown;
}

void DumpAllInjectedSources( IDiaSession* pSession)
{
    IDiaEnumInjectedSources* pEnumInjSources;

    pEnumInjSources = GetEnumInjectedSources(pSession);
    if (pEnumInjSources != NULL)
    {
        IDiaInjectedSource* pInjSource;
        ULONG celt = 0;

        while(pEnumInjSources->Next(1, &pInjSource, &celt) == S_OK &&
              celt == 1)
        {
            IDiaPropertyStorage *pPropertyStorage;
            if (pInjSource->QueryInterface(__uuidof(IDiaPropertyStorage),
                                          (void **)&pPropertyStorage) == S_OK)
            {
                PrintPropertyStorage(pPropertyStorage);
                pPropertyStorage->Release();
            }
            pInjSource->Release();
        }
        pEnumInjSources->Release();
    }
}

要求

标头:Dia2.h

库:diaguids.lib

DLL:msdia80.dll

另请参阅