WriteConsole (kernel32)
Last changed: -93.170.246.50

.
Summary

C# Signature:

[DllImport("kernel32.dll")]
static extern bool WriteConsole(IntPtr hConsoleOutput, string lpBuffer,
   uint nNumberOfCharsToWrite, out uint lpNumberOfCharsWritten,
   IntPtr lpReserved);

User-Defined Types:

None.

VB Signature:

Public Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, ByVal lpBuffer As String, ByVal nNumberOfCharsToWrite As Long, ByVal lpNumberOfCharsWritten As Long, ByVal lpReserved As IntPtr) As Long

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

public static IntPtr GetStdOut ()

{

  const int STD_OUTPUT_HANDLE = -11;
  IntPtr iStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
  return iStdOut;

}

public static short WriteConsoleLine ( string sLine )

{

  short cchWritten;
  if ( ! WriteConsole( GetStdOut(),
               sLine,
               (short) sLine.Length,
               out cchWritten,
               (IntPtr) 0 ) )
    return -1;
  return cchWritten;

}

Alternative Managed API:

Console.WriteLine()

Documentation