|
2 | 2 | title: "IDiaSession::findLinesByLinenum | Microsoft Docs"
|
3 | 3 | ms.date: "11/04/2016"
|
4 | 4 | ms.topic: "conceptual"
|
5 |
| -dev_langs: |
| 5 | +dev_langs: |
6 | 6 | - "C++"
|
7 |
| -helpviewer_keywords: |
| 7 | +helpviewer_keywords: |
8 | 8 | - "IDiaSession::findLinesByLinenum method"
|
9 | 9 | ms.assetid: 76d5622d-9a91-4c2a-a98f-263af5d1daef
|
10 | 10 | author: "mikejo5000"
|
11 | 11 | ms.author: "mikejo"
|
12 | 12 | manager: jillfra
|
13 |
| -ms.workload: |
| 13 | +ms.workload: |
14 | 14 | - "multiple"
|
15 | 15 | ---
|
16 | 16 | # IDiaSession::findLinesByLinenum
|
17 |
| -Determines the line numbers of the compiland that the specified line number in a source file lies within or near. |
18 |
| - |
19 |
| -## Syntax |
20 |
| - |
21 |
| -```C++ |
22 |
| -HRESULT findLinesByLinenum ( |
23 |
| - IDiaSymbol* compiland, |
24 |
| - IDiaSourceFile* file, |
25 |
| - DWORD linenum, |
26 |
| - DWORD column, |
27 |
| - IDiaEnumLineNumbers** ppResult |
28 |
| -); |
29 |
| -``` |
30 |
| - |
31 |
| -#### Parameters |
32 |
| - `compiland` |
33 |
| - [in] An [IDiaSymbol](../../debugger/debug-interface-access/idiasymbol.md) object that represents the compiland in which to search for the line numbers. This parameter cannot be `NULL`. |
34 |
| - |
35 |
| - `file` |
36 |
| - [in] An [IDiaSourceFile](../../debugger/debug-interface-access/idiasourcefile.md) object that represents the source file to search in. This parameter cannot be `NULL`. |
37 |
| - |
38 |
| - `linenum` |
39 |
| - [in] Specifies a one-based line number. |
40 |
| - |
| 17 | +Determines the line numbers of the compiland that the specified line number in a source file lies within or near. |
| 18 | + |
| 19 | +## Syntax |
| 20 | + |
| 21 | +```C++ |
| 22 | +HRESULT findLinesByLinenum ( |
| 23 | + IDiaSymbol* compiland, |
| 24 | + IDiaSourceFile* file, |
| 25 | + DWORD linenum, |
| 26 | + DWORD column, |
| 27 | + IDiaEnumLineNumbers** ppResult |
| 28 | +); |
| 29 | +``` |
| 30 | + |
| 31 | +#### Parameters |
| 32 | +`compiland` |
| 33 | +[in] An [IDiaSymbol](../../debugger/debug-interface-access/idiasymbol.md) object that represents the compiland in which to search for the line numbers. This parameter cannot be `NULL`. |
| 34 | + |
| 35 | +`file` |
| 36 | +[in] An [IDiaSourceFile](../../debugger/debug-interface-access/idiasourcefile.md) object that represents the source file to search in. This parameter cannot be `NULL`. |
| 37 | + |
| 38 | +`linenum` |
| 39 | +[in] Specifies a one-based line number. |
| 40 | + |
41 | 41 | > [!NOTE]
|
42 |
| -> You cannot use zero to specify all lines (use the [IDiaSession::findLines](../../debugger/debug-interface-access/idiasession-findlines.md) method to find all lines). |
43 |
| - |
44 |
| - `column` |
45 |
| - [in] Specifies the column number. Use zero to specify all columns. A column is a byte offset into a line. |
46 |
| - |
47 |
| - `ppResult` |
48 |
| - [out] Returns an [IDiaEnumLineNumbers](../../debugger/debug-interface-access/idiaenumlinenumbers.md) objta that contains a list of the line numbers retrieved. |
49 |
| - |
50 |
| -## Return Value |
51 |
| - If successful, returns `S_OK`; otherwise, returns an error code. |
52 |
| - |
53 |
| -## Example |
54 |
| - 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. |
55 |
| - |
56 |
| -```C++ |
57 |
| -void ShowLinesInCompilands(IDiaSession *pSession, LPCOLESTR filename) |
58 |
| -{ |
59 |
| - IDiaEnumSourceFiles* pEnum; |
60 |
| - IDiaSourceFile* pFile; |
61 |
| - DWORD celt; |
62 |
| - |
63 |
| - pSession->findFile ( NULL, filename, nsFNameExt, &pEnum ); |
64 |
| - while ( pEnum->Next ( 1, &pFile, &celt ) == S_OK ) // for each file |
65 |
| - { |
66 |
| - IDiaEnumSymbols* pEnumCompilands; |
67 |
| - IDiaSymbol* pCompiland; |
68 |
| - |
69 |
| - pFile->get_compilands ( &pEnumCompilands ); |
70 |
| - // for each compiland |
71 |
| - while ( pEnumCompilands->Next ( 1, &pCompiland, &celt ) == S_OK ) |
72 |
| - { |
73 |
| - IDiaEnumLineNumbers* pEnum; |
74 |
| - // Find first compiland closest to line 1 of the file. |
75 |
| - if (pSession->findLinesByLinenum( pCompiland, pFile, 1, 0, &pEnum ) == S_OK) |
76 |
| - { |
77 |
| - IDiaLineNumber *pLineNumber; |
78 |
| - DWORD lineCount; |
79 |
| - while ( pEnum->Next(1,&pLineNumber,&lineCount) == S_OK) |
80 |
| - { |
81 |
| - DWORD lineNum; |
82 |
| - if (pLineNumber->get_line(&lineNum) == S_OK) |
83 |
| - { |
84 |
| - printf("compiland starts in source at line number = %lu\n",lineNum); |
85 |
| - } |
86 |
| - } |
87 |
| - } |
88 |
| - } |
89 |
| - } |
90 |
| -} |
91 |
| -``` |
92 |
| - |
93 |
| -## See Also |
94 |
| - [IDiaEnumLineNumbers](../../debugger/debug-interface-access/idiaenumlinenumbers.md) |
95 |
| - [IDiaSession](../../debugger/debug-interface-access/idiasession.md) |
96 |
| - [IDiaSession::findLinesByAddr](../../debugger/debug-interface-access/idiasession-findlinesbyaddr.md) |
97 |
| - [IDiaSourceFile](../../debugger/debug-interface-access/idiasourcefile.md) |
98 |
| - [IDiaSymbol](../../debugger/debug-interface-access/idiasymbol.md) |
| 42 | +> You cannot use zero to specify all lines (use the [IDiaSession::findLines](../../debugger/debug-interface-access/idiasession-findlines.md) method to find all lines). |
| 43 | +
|
| 44 | +`column` |
| 45 | +[in] Specifies the column number. Use zero to specify all columns. A column is a byte offset into a line. |
| 46 | + |
| 47 | +`ppResult` |
| 48 | +[out] Returns an [IDiaEnumLineNumbers](../../debugger/debug-interface-access/idiaenumlinenumbers.md) objta that contains a list of the line numbers retrieved. |
| 49 | + |
| 50 | +## Return Value |
| 51 | +If successful, returns `S_OK`; otherwise, returns an error code. |
| 52 | + |
| 53 | +## Example |
| 54 | +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. |
| 55 | + |
| 56 | +```C++ |
| 57 | +void ShowLinesInCompilands(IDiaSession *pSession, LPCOLESTR filename) |
| 58 | +{ |
| 59 | + IDiaEnumSourceFiles* pEnum; |
| 60 | + IDiaSourceFile* pFile; |
| 61 | + DWORD celt; |
| 62 | + |
| 63 | + pSession->findFile ( NULL, filename, nsFNameExt, &pEnum ); |
| 64 | + while ( pEnum->Next ( 1, &pFile, &celt ) == S_OK ) // for each file |
| 65 | + { |
| 66 | + IDiaEnumSymbols* pEnumCompilands; |
| 67 | + IDiaSymbol* pCompiland; |
| 68 | + |
| 69 | + pFile->get_compilands ( &pEnumCompilands ); |
| 70 | + // for each compiland |
| 71 | + while ( pEnumCompilands->Next ( 1, &pCompiland, &celt ) == S_OK ) |
| 72 | + { |
| 73 | + IDiaEnumLineNumbers* pEnum; |
| 74 | + // Find first compiland closest to line 1 of the file. |
| 75 | + if (pSession->findLinesByLinenum( pCompiland, pFile, 1, 0, &pEnum ) == S_OK) |
| 76 | + { |
| 77 | + IDiaLineNumber *pLineNumber; |
| 78 | + DWORD lineCount; |
| 79 | + while ( pEnum->Next(1,&pLineNumber,&lineCount) == S_OK) |
| 80 | + { |
| 81 | + DWORD lineNum; |
| 82 | + if (pLineNumber->get_line(&lineNum) == S_OK) |
| 83 | + { |
| 84 | + printf("compiland starts in source at line number = %lu\n",lineNum); |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | +} |
| 91 | +``` |
| 92 | +
|
| 93 | +## See Also |
| 94 | +[IDiaEnumLineNumbers](../../debugger/debug-interface-access/idiaenumlinenumbers.md) |
| 95 | +[IDiaSession](../../debugger/debug-interface-access/idiasession.md) |
| 96 | +[IDiaSession::findLinesByAddr](../../debugger/debug-interface-access/idiasession-findlinesbyaddr.md) |
| 97 | +[IDiaSourceFile](../../debugger/debug-interface-access/idiasourcefile.md) |
| 98 | +[IDiaSymbol](../../debugger/debug-interface-access/idiasymbol.md) |
0 commit comments