[API]
CreateFileA
CreateFileW
Public CloseHandle

[DEFINE]
Public Enum eCreateFileMode
  ReadOnly = 0
  WriteOnly = 1
  ReadWrite = 2
  End Enum

[CODE]
Public Function CreateFile(ByVal Filename As String, ByVal xMode As eCreateFileMode) As Long
  Dim xLong1 As Long

  Select Case xMode
    Case ReadOnly:  xLong1 = &H80000000: CreateFile = 3&
    Case WriteOnly: xLong1 = &H40000000: CreateFile = 2&
    Case ReadWrite: xLong1 = &HC0000000: CreateFile = 3&
    End Select

  If IsUnicode Then
    CreateFile = CreateFileW(ByVal StrPtr(Filename), xLong1, &H1&, 0&, CreateFile, &H20&, 0&)
    Else
    CreateFile = CreateFileA(Filename, xLong1, &H1&, 0&, CreateFile, &H20&, 0&)
    End If
  End Function

