Results 1 to 40 of 64

Thread: VB6 - Huge (>2GB) File I/O Class

Threaded View

  1. #11
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: VB6 - Huge (>2GB) File I/O Class

    Quote Originally Posted by dilettante View Post
    Since this Class does not deal with text at all, there is no need for the W entrypoints.

    However if you want to use Unicode file names then you have a valid point, and CreateFile needs to be CreateFileW with a few other minor changes to its signature and call.
    Use CreateFileW in your OpenFile function.


    I have no idea why you are using LCMapString though, except perhaps as a fancy version of StrConv?
    I just copy all APIs from my another project which deal with Unicode text file. LCMAPStringW for GB2GBK conversion.
    Code:
    Public Function GB2GBK(ByVal CSstring As String) As String
    
      Dim lLen As Long
      Dim CTString As String
    
        On Error GoTo ToExit
    
        If CSstring = vbNullString Then Exit Function
        If m_bisNT Then
            lLen = lstrlenW(StrPtr(CSstring))
            CTString = Space$(lLen)
            LCMapStringW &H804, &H4000000, StrPtr(CSstring), lLen, StrPtr(CTString), lLen * 2
            GB2GBK = CTString
          Else
            lLen = lstrlen(CSstring)
            CTString = Space$(lLen)
            LCMapString &H804, &H4000000, CSstring, lLen, CTString, lLen
            GB2GBK = CTString
        End If
    
    Exit Function
    
    ToExit:
        GB2GBK = vbNullString
    
    End Function
    The nice thing about having the source is that you can hack away and make any customization you want though. If there really is a bug perhaps you can explain it in more detail?
    Public Function ReadBytes(ByRef Buffer() As Byte) As Long

    RaiseErrorIfClosed

    If ReadFile(hFile, _
    Buffer(LBound(Buffer)), _
    UBound(Buffer) - LBound(Buffer) + 1, _
    ReadBytes, _
    0) Then

    If ReadBytes = 0 Then
    fEOF = True
    ElseIf ReadBytes < UBound(Buffer) - LBound(Buffer) + 1 Then
    ReDim Preserve Buffer(ReadBytes - 1)

    End If
    Else
    RaiseError HBF_READ_FAILURE
    End If
    End Function
    Last edited by Jonney; Aug 4th, 2011 at 09:53 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width