Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


Determines the line numbers of the compiland that the specified line number in a source file lies within or near.

HRESULT findLinesByLinenum ( 
   IDiaSymbol*           compiland,
   IDiaSourceFile*       file,
   DWORD                 linenum,
   DWORD                 column,
   IDiaEnumLineNumbers** ppResult


[in] An IDiaSymbol object that represents the compiland in which to search for the line numbers. This parameter cannot be NULL.


[in] An IDiaSourceFile object that represents the source file to search in. This parameter cannot be NULL.


[in] Specifies a one-based line number.

Note Note

You cannot use zero to specify all lines (use the IDiaSession::findLines method to find all lines).


[in] Specifies the column number. Use zero to specify all columns. A column is a byte offset into a line.


[out] Returns an IDiaEnumLineNumbers objta that contains a list of the line numbers retrieved.

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

The following example shows how to open a source file, enumerate the compilands contributed by this file, and locate the line numbers in the source file where each compiland starts.

void ShowLinesInCompilands(IDiaSession *pSession, LPCOLESTR filename)
    IDiaEnumSourceFiles* pEnum;
    IDiaSourceFile*      pFile;
    DWORD                celt;

    pSession->findFile ( NULL, filename, nsFNameExt, &pEnum );
    while ( pEnum->Next ( 1, &pFile, &celt ) == S_OK ) // for each file
        IDiaEnumSymbols* pEnumCompilands;
        IDiaSymbol* pCompiland;

        pFile->get_compilands ( &pEnumCompilands );
        // for each compiland
        while ( pEnumCompilands->Next ( 1, &pCompiland, &celt ) == S_OK )
            IDiaEnumLineNumbers* pEnum;
            // Find first compiland closest to line 1 of the file.
            if (pSession->findLinesByLinenum( pCompiland, pFile, 1, 0, &pEnum ) == S_OK)
                IDiaLineNumber *pLineNumber;
                DWORD lineCount;
                while ( pEnum->Next(1,&pLineNumber,&lineCount) == S_OK)
                     DWORD lineNum;
                     if (pLineNumber->get_line(&lineNum) == S_OK)
                          printf("compiland starts in source at line number = %lu\n",lineNum);
© 2015 Microsoft