function GetFileText(const FileName: string): string;<br>var<br> hFile: DWORD;<br> iSize: DWORD;<br> sTemp: string;<br>begin<br> hFile := CreateFile(PChar(FileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);<br> iSize := GetFileSize(hFile, nil);<br> SetLength(sTemp, iSize + 2);<br> ReadFile(hFile, sTemp[1], iSize, iSize, nil);<br> CloseHandle(hFile);<br> sTemp[iSize + 1] := #0;<br> sTemp[iSize + 2] := #0;<br> if (sTemp[1] = #$FF) and (sTemp[2] = #$FE) then // UNICODE<br> begin<br> SetLength(Result, iSize);<br> WideCharToMultiByte(CP_ACP, 0, PWideChar(@sTemp[3]), -1, @Result[1], iSize, nil, nil);<br> end else<br> Result := sTemp;<br> Result := string(PChar(Result));<br>end; <br>用这个函数取出并转换,而所谓一行行读无非就是定位#13#10.