[API]
CreateFileA
CreateFileW
CloseHandle

[DEFINE]
Public Enum eCreateFileOpenMode
  CreateAlwaysNew = 2&
  OpenExisting = 3&
  CreateOrReuse = 4&
  End Enum

Public Enum eCreateFileAccessMode
  FILE_READ = &H80000000
  FILE_WRITE = &H40000000
  FILE_READWRITE = &HC0000000
  End Enum

[CODE]
Public Function CreateFile(ByVal Filename As String, ByVal xOpenMode As eCreateFileOpenMode, ByVal xAccessMode As eCreateFileAccessMode) As Long
  If IsUnicode Then
    CreateFile = CreateFileW(ByVal StrPtr(Filename), xAccessMode, &H1&, 0&, xOpenMode, &H20&, 0&)
    Else
    CreateFile = CreateFileA(Filename, xAccessMode, &H1&, 0&, xOpenMode, &H20&, 0&)
    End If
  End Function

