Microsoft KB Archive/89750

{|
 * width="100%"|

INFO: AllocConsole Necessary to Get Valid Handles

 * }

Q89750

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * the operating system: Microsoft Windows NT, versions 3.1, 3.5, 3.51, 4.0
 * the operating system: Microsoft Windows 2000

-

SUMMARY
If a graphical user interface (GUI) application redirects a standard handle, such as stderr or stdout, and then spawns a child process, the output of the child process will not be seen unless the AllocConsole application programming interface (API) is called by the parent before spawning the child.

If an application spawns a child process without calling AllocConsole first, then a new console output window is created for the child. The child's console window appears on the screen and the GUI application is not be able to control this window (for example, it cannot minimize the child window). In addition, users can terminate the child process by choosing Close from the console window's Control (system) menu. This causes users to think that only the window is closed, when in actuality, the entire application is terminated. This can cause the user to lose data in the console window.

Additional query words:

Keywords : kbprogramming kbConsole kbFileIO kbKernBase kbOSWinNT310 kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbDSupport kbGrpDSKernBase

Issue type : kbinfo

Technology : kbAudDeveloper kbWin32sSearch kbWin32API