다음을 통해 공유


IVsTextLines.CopyLineText(Int32, Int32, Int32, Int32, IntPtr, Int32) Method

Definition

Puts the specified span of text into a caller-allocated buffer (an array).

public:
 int CopyLineText(int iStartLine, int iStartIndex, int iEndLine, int iEndIndex, IntPtr pszBuf, [Runtime::InteropServices::Out] int % pcchBuf);
public int CopyLineText (int iStartLine, int iStartIndex, int iEndLine, int iEndIndex, IntPtr pszBuf, out int pcchBuf);
abstract member CopyLineText : int * int * int * int * nativeint * int -> int
Public Function CopyLineText (iStartLine As Integer, iStartIndex As Integer, iEndLine As Integer, iEndIndex As Integer, pszBuf As IntPtr, ByRef pcchBuf As Integer) As Integer

Parameters

iStartLine
Int32

[in] Starting line.

iStartIndex
Int32

[in] Starting character index within the line. Must be less than or equal to the length of the line.

iEndLine
Int32

[in] Ending line.

iEndIndex
Int32

[in] Ending character index within the line. Must be less than or equal to the length of the line.

pszBuf
IntPtr

nativeint

[in] Pointer to a caller-allocated buffer.

pcchBuf
Int32

[in, out] Pointer to a count of Unicode characters — not bytes.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsTextLines::CopyLineText(  
   [in] long iStartLine,  
   [in] CharIndex iStartIndex,  
   [in] long iEndLine,  
   [in] CharIndex iEndIndex,  
   [in] LPWSTR pszBuf,  
   [in, out] long *pcchBuf  
);  

To determine the size of the array necessary to hold a given span of text, call IVsTextLines.CopyLineText and pass in the starting and ending positions in the buffer and null for the pszBuf parameter. This method then returns the size of the array in the pcchBuf parameter.

This method copies up to pcchBuf characters into the buffer you allocate. If the buffer is not large enough to hold these characters, the method returns BUFFER_E_DEST_TOO_SMALL and sets the pcchBuf parameter to the required size.

Note

The CopyLineText method does not append null to the output string.

IVsTextLines.CopyLineText is used as an optimization over methods that require the buffer to allocate the memory for them, such as GetLineText. In the case of this method, the text buffer allocates a BSTR, which has a fairly significant performance cost if the method is called repeatedly. For IVsTextLines.CopyLineText, however, you can repeatedly copy over the buffer you allocate if you call this method repeatedly.

Applies to