[API]
GetStdHandle
GetConsoleOutputCP
WriteConsoleA
WriteConsoleW

[INCLUDE]
CPEncode

[CODE]
Public Function WriteConsole(ByVal xChar1 As String) As Boolean
  Dim xLong1 As Long
  Dim xLong2 As Long
  Dim xLong3 As Long

  xLong1 = GetStdHandle(-11&)
  If Not xLong1 = -1& Then
    If IsUnicode Then
      xLong2 = Len(xChar1)
      xLong1 = WriteConsoleW(xLong1, ByVal StrPtr(xChar1), xLong2, xLong3, 0&)
      Else
      xChar1 = CPEncode(GetConsoleOutputCP, xChar1)
      xLong1 = WriteConsoleA(xLong1, ByVal xChar1, Len(xChar1), xLong3, 0&)
      End If
    WriteConsole = (xLong3 = Len(xChar1) And Not xLong1 = 0&)
    End If
  End Function