Sets the handle for the specified standard device (standard input, standard output, or standard error).
BOOL WINAPI SetStdHandle( _In_ DWORD nStdHandle, _In_ HANDLE hHandle );
The standard device for which the handle is to be set. This parameter can be one of the following values.
||The standard input device. Initially, this is the console input buffer,
||The standard output device. Initially, this is the active console screen buffer,
||The standard error device. Initially, this is the active console screen buffer,
The values for these constants are unsigned numbers, but are defined in the header files as a cast from a
signed number and take advantage of the C compiler rolling them over to just under the maximum 32-bit value. When interfacing with these handles in a language that does not parse the headers and is re-defining the constants, please be aware of this constraint. As an example,
((DWORD)-10) is actually the unsigned number
The handle for the standard device.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The standard handles of a process may have been redirected by a call to SetStdHandle, in which case GetStdHandle will return the redirected handle. If the standard handles have been redirected, you can specify the CONIN$ value in a call to the CreateFile function to get a handle to a console's input buffer. Similarly, you can specify the CONOUT$ value to get a handle to the console's active screen buffer.
For an example, see Creating a Child Process with Redirected Input and Output.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||ProcessEnv.h (via Winbase.h, include Windows.h)|