IDebugHostSymbols::EnumerateModules 方法 (dbgmodel.h)

EnumerateModules 方法會建立列舉值,以列舉特定主機內容中可用的每個模組。 該主機內容可能會封裝進程內容,或封裝類似 Windows 核心的內容。

語法

HRESULT EnumerateModules(
  IDebugHostContext          *context,
  IDebugHostSymbolEnumerator **moduleEnum
);

參數

context

要列舉每個載入模組的主機內容。

moduleEnum

列舉值,將列舉載入至指定內容的每個模組,將會在這裡傳回。

傳回值

這個方法會傳回 HRESULT,指出成功或失敗。

備註

範例程式碼

ComPtr<IDebugHost> spHost; /* get the host */

ComPtr<IDebugHostSymbols> spSym;
if (SUCCEEDED(spHost.As(&spSym)))
{
    // Enumerate all modules in the current UI context (process) of the debug host:
    ComPtr<IDebugHostSymbolEnumerator> spEnum;
    if (SUCCEEDED(spSym->EnumerateModules(USE_CURRENT_HOST_CONTEXT, &spEnum)))
    {
        HRESULT hr = S_OK;
        while (SUCCEEDED(hr))
        {
            ComPtr<IDebugHostSymbol> spModSym;
            hr = spEnum->GetNext(&spModSym);
            if (SUCCEEDED(hr))
            {
                ComPtr<IDebugHostModule> spModule;
                if (SUCCEEDED(spModSym.As(&spModule))) /* should always succeed */
                {
                    // spModule is one of the modules in the current
                    // UI context (process) of the debug host
                }
            }
        }

        // hr == E_BOUNDS : hit the end of the enumerator
        // hr == E_ABORT  : a user interrupt was requested / 
        //                  propagate upwards immediately
    }
}

規格需求

需求
標頭 dbgmodel.h

另請參閱

IDebugHostSymbols 介面