IEnumerable<PdbSourceFile^>^ PdbSession::SourceFiles::get() { IDiaEnumTables* diaEnumTables = nullptr; if (FAILED(diaSession->getEnumTables(&diaEnumTables))) return nullptr; if (diaEnumTables == nullptr) return nullptr; ULONG celt = 0; IDiaTable* diaTable = nullptr; while (SUCCEEDED(diaEnumTables->Next(1, &diaTable, &celt)) && celt == 1) { IDiaEnumSourceFiles* diaEnumSourceFiles; if (SUCCEEDED(diaTable->QueryInterface(_uuidof(IDiaEnumSourceFiles), (void**)&diaEnumSourceFiles))) return diaEnumSourceFiles ? gcnew PdbSourceFileCollection(diaEnumSourceFiles) : nullptr; } return nullptr; }
static IDiaEnumSegments* GetEnumSegments(IDiaSession *pSession) { IDiaEnumSegments* pUnknown = NULL; IDiaEnumTables* pEnumTables = NULL; IDiaTable* pTable = NULL; ULONG celt = 0; if ( pSession->getEnumTables(&pEnumTables) != S_OK ) return nullptr; while (pEnumTables->Next(1, &pTable, &celt) == S_OK && celt == 1) { // There is only one table that matches the given iid HRESULT hr = pTable->QueryInterface(__uuidof(IDiaEnumSegments), (void**)&pUnknown); pTable->Release(); if (hr == S_OK) break; } pEnumTables->Release(); return pUnknown; }
I* GetEnumTable(IDiaSession *pSession) { I* pUnknown = NULL; REFIID iid = __uuidof(I); 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; }