Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

WriteConsole (kernel32)
 
.
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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions