[API]
GetFileSize
ReadFile
SetFilePointer

[INCLUDE]
CreateFile

[CODE]
Public Function ReadCompleteTxtFile(ByVal FileName As String, ByRef FileData As String) As Boolean
  Dim xLong1 As Long
  Dim xLong2 As Long
  Dim xLong3 As Long

  xLong1 = CreateFile(FileName, OpenExisting, FILE_READ)
  If Not xLong1 = 0& Then
    xLong2 = GetFileSize(xLong1, xLong3)
    If xLong3 = 0& And xLong2 < &H40000000 And Not xLong2 = 0& Then
      If Not ReadFile(xLong1, ByVal VarPtr(xLong3), 2&, 0&, 0&) = 0& Then
        If (xLong3 And &HFFFF&) = &HFEFF& Then
          If xLong2 Mod 2& = 0& Then
            xLong2 = xLong2 - 2&
            FileData = String(xLong2 \ 2&, vbNullChar) + vbCrLf
            If Not ReadFile(xLong1, ByVal StrPtr(FileData), xLong2, xLong3, 0&) = 0& Then
              If xLong2 = xLong3 Then
                ReadCompleteTxtFile = True
                End If
              End If
            End If
          ElseIf Not SetFilePointer(xLong1, 0&, 0&, 0&) = -1& Then
          FileData = String(xLong2, vbNullChar) + vbCrLf
          If Not ReadFile(xLong1, ByVal FileData, xLong2, xLong3, 0&) = 0& Then
            If xLong2 = xLong3 Then
              ReadCompleteTxtFile = True
              End If
            End If
          End If
        End If
      End If
    Call CloseHandle(xLong1)
    End If
  End Function
