共用方式為


IDiaSession::findLinesByAddr

擷取指定編譯模組中包含指定位址的各行。

語法

HRESULT findLinesByAddr (
    DWORD                 seg,
    DWORD                 offset,
    DWORD                 length,
    IDiaEnumLineNumbers** ppResult
);

參數

seg

[in] 指定特定位址的區段元件。

offset

[in] 指定特定位址的位移元件。

length

[in] 指定此查詢所涵蓋的位址範圍位元組數目。

ppResult

[out] 傳回 IDiaEnumLineNumbers 物件,其中包含涵蓋指定位址範圍的所有行號清單。

傳回值

如果成功,則會傳回 S_OK;否則,會傳回錯誤碼。

範例

在這個範例中,會示範函式使用函式的位址和長度,取得函式中包含的所有行號。

IDiaEnumLineNumbers* GetLineNumbersByAddr(IDiaSymbol *pFunc,
                                          IDiaSession *pSession)
{
    IDiaEnumLineNumbers* pEnum = NULL;
    DWORD                seg;
    DWORD                offset;
    ULONGLONG            length;

    if (pFunc->get_addressSection ( &seg ) == S_OK &&
        pFunc->get_addressOffset ( &offset ) == S_OK)
    {
        pFunc->get_length ( &length );
        pSession->findLinesByAddr( seg, offset, static_cast<DWORD>( length ), &pEnum );
    }
    return(pEnum);
}

另請參閱