[API]
LocalFree
RtlMoveMemory
CallWindowProcA

[ASSEMBLY]
StrStrW_Cr_Lf_CrLf

[INCLUDE]
UIntAddUInt
UIntSubUInt
TxtFile_ReadOpen

[CODE]
Public Function TxtFile_ReadLine(ByVal hTxtFileIn As Long, ByRef xLine As String) As Boolean
  Dim xLong1 As Long
  Dim xLong2 As Long
  Dim xLong3 As Long
  Dim xType1 As TxtFileReadStruct

  xLine = ""
  If Not hTxtFileIn = 0& Then
    Call RtlMoveMemory(xType1, ByVal hTxtFileIn, TxtFileReadStructLen)
    If Not (xType1.hMem = 0& Or xType1.hMemPos = xType1.hMemEnd) Then
      xLong1 = CallWindowProcA(StrStrW_Cr_Lf_CrLf_Exe, 0&, 0&, xType1.hMemPos, VarPtr(xLong3))
      If xLong1 = 0& Then
        Call LocalFree(xType1.hMem)
        xType1.hMem = 0&
        GoTo FailReWriteStruct
        Else
        xLong2 = xLong1
        UIntSubUInt xLong2, xType1.hMemPos
        If Not xLong2 = 0& Then
          xLine = String(xLong2 / 2&, vbNullChar)
          Call RtlMoveMemory(ByVal StrPtr(xLine), ByVal xType1.hMemPos, xLong2)
          End If
        UIntAddUInt xLong1, xLong3
        xType1.hMemPos = xLong1
        TxtFile_ReadLine = True
FailReWriteStruct:
        Call RtlMoveMemory(ByVal hTxtFileIn, xType1, TxtFileReadStructLen)
        End If
      End If
    End If
  End Function