function TMemoStrings.GetCount: Integer;<br>begin<br> Result := 0;<br> if Memo.HandleAllocated or (Memo.WindowText <> nil) then<br> begin<br> Result := SendMessage(Memo.Handle, EM_GETLINECOUNT, 0, 0);<br> if SendMessage(Memo.Handle, EM_LINELENGTH, SendMessage(Memo.Handle,<br> EM_LINEINDEX, Result - 1, 0), 0) = 0 then Dec(Result);<br> end;<br>end;<br><br>function TMemoStrings.Get(Index: Integer): string;<br>var<br> Text: array[0..4095] of Char;<br>begin<br> Word((@Text)^) := SizeOf(Text);<br> SetString(Result, Text, SendMessage(Memo.Handle, EM_GETLINE, Index,<br> Longint(@Text)));<br>end;<br>第一个作用是返回行数,最后一行能为空。<br>第二个是得到 所在行的长度,输出字符到Text中。