C# .NET
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();
None.
None.
Please add some!
if(GetConsoleWindow() != IntPtr.Zero)
{
TextWriterTraceListener ConsoleListener = new TextWriterTraceListener(System.Console.Out);
Trace.Listeners.Add(ConsoleListener);
}
Visual Basic .NET
<DllImport("kernel32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Function GetConsoleWindow() As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As ShowWindowCommands) As Boolean
End Function
Enum ShowWindowCommands As Integer
Hide = 0
Normal = 1
ShowMinimized = 2
ShowMaximized = 3
ShowNoActivate = 4
Show = 5
Minimize = 6
ShowMinNoActive = 7
ShowNA = 8
Restore = 9
ShowDefault = 10
ForceMinimize = 11
End Enum
Dim hwnd As New IntPtr(0)
hwnd = GetConsoleWindow()
If (hwnd <> IntPtr.Zero) Then
ShowWindow(hwnd, ShowWindowCommands.ShowMinimized)
End If
Do you know one? Please contribute it!