|
Creation of a Console
Microsoft Windows® creates a new console when it starts a console process, a character-mode process whose entry point is the main function. For example, Windows creates a new console when it starts the
command processor. When the command processor starts a new console process, the user
can specify whether the system creates a new console for the new process or
whether it inherits the command processor's console. A process can create a
console by using one of the following methods:
- A graphical user interface (GUI) or console process that is not currently
attached to a console can use the AllocConsole function to create a new console.
- A GUI or console process can use the CreateProcess function to create a new console process and specify a flag to tell the
system to create a new console.
Typically, a process uses AllocConsole to create a console when an error occurs requiring interaction with the user.
For example, a GUI process can create a console when an error occurs that
prevents it from using its normal graphical interface, or a console process that
does not normally interact with the user can create a console when an error makes
it necessary. The process that calls AllocConsole must not be attached to an existing console. GUI processes are not attached
to any console when they are created. A console process is not attached to a
console if the DETACHED_PROCESS flag was specified in a call to CreateProcess when the process was created. A process can use the FreeConsole function to detach itself from an inherited console or from a console created
by AllocConsole.
A process can also create a console by specifying the CREATE_NEW_CONSOLE flag
in a call to CreateProcess. This method creates a new console that is accessible to the child process
but not to the parent process. Separate consoles enable both parent and child
processes to interact with the user without conflict. If this flag is not
specified when a console process is created, both processes are attached to the same
console, and there is no guarantee that the correct process will receive the
input intended for it. Applications can prevent confusion by creating child
processes that do not inherit handles of the input buffer, or by enabling only one
child process at a time to inherit an input buffer handle while preventing the
parent process from reading console input until the child has finished.
Creating a new console results in a new console window, as well as separate
I/O screen buffers. The process associated with the new console uses the GetStdHandle function to get the handles of the new console's input and screen buffers.
These handles enable the process to access the console.
When a process uses CreateProcess, it can specify a STARTUPINFO structure, whose members control the characteristics of the first new console
(if any) created for the child process. The STARTUPINFO structure specified in the call to CreateProcess affects a console created if the CREATE_NEW_CONSOLE flag is specified. It
also affects a console created if the child process subsequently uses AllocConsole. The following console characteristics can be specified:
- The size, in character cells, and the location, in screen pixel coordinates,
of the new console window
- The size, in character cells, of the new console's screen buffer
- The text and background color attributes of the new console's screen buffer
- The name appearing in the title bar of the new console's window
The system uses default values if the STARTUPINFO values are not specified. A child process can use the GetStartupInfo function to determine the values in its STARTUPINFO structure.
A process cannot change the location of its console window on the screen, but
the following console functions are available to set or retrieve the other
properties specified in the STARTUPINFO structure.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|