共用方式為


IDiaSession::getEnumTables

Note

This article applies to Visual Studio 2015. 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

Retrieves an enumerator for all tables contained in the symbol store.

Syntax

HRESULT getEnumTables (   
   IDiaEnumTables** ppEnumTables  
);  

Parameters

ppEnumTables
[out] Returns an IDiaEnumTables object. Use this interface to enumerate the tables in the symbol store.

Return Value

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

Example

This example presents a general function that uses the getEnumTables method to obtain a specific enumerator object. If the enumerator is found, the function returns a pointer that can be cast to the desired interface; otherwise, the function returns NULL.

IUnknown *GetTable(IDiaSession *pSession, REFIID iid)  
{  
    IUnknown *pUnknown = NULL;  
    if (pSession != NULL)  
    {  
        CComPtr<IDiaEnumTables> pEnumTables;  
        if (pSession->getEnumTables(&pEnumTables) == S_OK)  
        {  
             CComPtr<IDiaTable> pTable;  
             DWORD celt = 0;  
             while(pEnumTables->Next(1,&pTable,&celt) == S_OK &&  
                   celt == 1)  
             {  
                  if (pTable->QueryInterface(iid, (void **)pUnknown) == S_OK)  
                  {  
                       break;  
                  }  
                  pTable = NULL;  
             }  
        }  
    }  
    return(pUnknown);  
}  

See Also

IDiaEnumTables
IDiaSession