Partilhar via


Método IVsTextLines.CopyLineText

Coloca o período especificado de texto em um buffer alocado pelo chamador (uma matriz).

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop (em Microsoft.VisualStudio.TextManager.Interop.dll)

Sintaxe

'Declaração
Function CopyLineText ( _
    iStartLine As Integer, _
    iStartIndex As Integer, _
    iEndLine As Integer, _
    iEndIndex As Integer, _
    pszBuf As IntPtr, _
    <OutAttribute> ByRef pcchBuf As Integer _
) As Integer
int CopyLineText(
    int iStartLine,
    int iStartIndex,
    int iEndLine,
    int iEndIndex,
    IntPtr pszBuf,
    out int pcchBuf
)
int CopyLineText(
    [InAttribute] int iStartLine, 
    [InAttribute] int iStartIndex, 
    [InAttribute] int iEndLine, 
    [InAttribute] int iEndIndex, 
    [InAttribute] IntPtr pszBuf, 
    [InAttribute] [OutAttribute] int% pcchBuf
)
abstract CopyLineText : 
        iStartLine:int * 
        iStartIndex:int * 
        iEndLine:int * 
        iEndIndex:int * 
        pszBuf:IntPtr * 
        pcchBuf:int byref -> int
function CopyLineText(
    iStartLine : int, 
    iStartIndex : int, 
    iEndLine : int, 
    iEndIndex : int, 
    pszBuf : IntPtr, 
    pcchBuf : int
) : int

Parâmetros

  • iStartLine
    Tipo: Int32

    [in] Linha inicial.

  • iStartIndex
    Tipo: Int32

    [in] Índice de caractere inicial dentro da linha. Deve ser menor ou igual ao comprimento da linha.

  • iEndLine
    Tipo: Int32

    [in] Final de linha.

  • iEndIndex
    Tipo: Int32

    [in] Índice do caractere de final dentro da linha. Deve ser menor ou igual ao comprimento da linha.

  • pszBuf
    Tipo: IntPtr

    [in] Ponteiro para um buffer alocado pelo chamador.

  • pcchBuf
    Tipo: Int32%

    [in, out] Ponteiro para uma contagem de caracteres Unicode — não em bytes.

Valor de retorno

Tipo: Int32
Se o método for bem-sucedido, ele retorna S_OK.Se ele falhar, ele retorna um código de erro.

Comentários

COM assinatura

De textmgr.idl:

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

Para determinar o tamanho da matriz necessários para manter um determinado trecho de texto, chame IVsTextLines.CopyLineText e passe iniciais e finais posições no buffer e nulluma referência nula (Nothing no Visual Basic) para o pszBuf parâmetro. Esse método retorna o tamanho da matriz na pcchBuf parâmetro.

Esse método copia até pcchBuf caracteres no buffer é alocado. Se o buffer não é grande o suficiente para conter esses caracteres, o método retorna BUFFER_E_DEST_TOO_SMALL e define o pcchBuf parâmetro para o tamanho necessário.

Dica

O CopyLineText método não acrescenta nulluma referência nula (Nothing no Visual Basic) para a seqüência de saída.

IVsTextLines.CopyLineTexté usado como uma otimização sobre os métodos que requerem o buffer para alocar a memória para eles, como GetLineText. No caso desse método, o buffer de texto aloca um BSTR, que tem um desempenho bastante significativo de custo se o método é chamado repetidamente. Para IVsTextLines.CopyLineText, Entretanto, você pode copiar repetidamente sobre o buffer é alocado se você chamar esse método repetidamente.

Segurança do .NET Framework

Consulte também

Referência

IVsTextLines Interface

Namespace Microsoft.VisualStudio.TextManager.Interop