lBytesWritten
   
End Function

Private Function AllocateBuffer(ByVal lSize As Long) As Long
   m_hMem = LocalAlloc(GPTR, lSize)
   If (m_hMem = 0) Then
      errHandler "AllocateBuffer", 1
      Exit Function
   End If
   m_ptrMem = LocalLock(m_hMem)
   If (m_ptrMem = 0) Then
      freeBuffer
      errHandler "AllocateBuffer", 1
      Exit Function
   End If
   AllocateBuffer = True
End Function

Private Sub freeBuffer()
   If Not (m_ptrMem = 0) Then
      LocalUnlock m_hMem
      m_ptrMem = 0
   End If
  