If you need to check for an existing console (ie, if the program was launched from the command window) please see AttachConsole,
Attach current process to the console of a specified process, or to the current one by default (see ATTACH_PARENT_PROCESS) (this is an large contrib article, and since the net add-in insists on using this one, i decided to place it here and not in the original place.)
/// always pass this with AttachConsole in .NET for stability reasons and mainly because
.
if (!AttachConsole(ATTACH_PARENT_PROCESS) && Marshal.GetLastWin32Error() == ERROR_ACCESS_DENIED)
.
Attach current process to the console of a specified process, or to the current one by default (see ATTACH_PARENT_PROCESS) (this is an large contrib article, and since the net add-in insists on using this one, i decided to place it here and not in the original place.)
/// always pass this with AttachConsole in .NET for stability reasons and mainly because
.
if (!AttachConsole(ATTACH_PARENT_PROCESS) && Marshal.GetLastWin32Error() == ERROR_ACCESS_DENIED)
.
Attach current process to the console of a specified process, or to the current one by default (see ATTACH_PARENT_PROCESS) (this is an large contrib article, and since the net add-in insists on using this one, i decided to place it here and not in the original place.)
Attach current process to the console of a specified process, or to the current one by default (see ATTACH_PARENT_PROCESS) (this is an large contrib article, and since the net add-in insists on using this one, i decided to place it here and not in the original place.)