Permalink
Fetching contributors…
Cannot retrieve contributors at this time
165 lines (132 sloc) 3.78 KB
title description author ms.author ms.topic ms.prod keywords MS-HAID MSHAttr ms.assetid topic_type api_name api_location api_type
SetStdHandle function
Sets the handle for the specified standard device (standard input, standard output, or standard error).
bitcrazed
richturn
article
console
console, character mode applications, command line applications, terminal applications, console api
\_win32\_setstdhandle
base.setstdhandle
consoles.setstdhandle
PreferredSiteName:MSDN
PreferredLib:/library/windows/desktop
f5952460-1839-415e-b400-2f04425f288a
apiref
SetStdHandle
Kernel32.dll
API-MS-Win-Core-ProcessEnvironment-l1-1-0.dll
KernelBase.dll
API-MS-Win-Core-ProcessEnvironment-l1-2-0.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
DllExport

SetStdHandle function

Sets the handle for the specified standard device (standard input, standard output, or standard error).

Syntax

BOOL WINAPI SetStdHandle(
  _In_ DWORD  nStdHandle,
  _In_ HANDLE hHandle
);

Parameters

nStdHandle [in]
The standard device for which the handle is to be set. This parameter can be one of the following values.

Value Meaning
STD_INPUT_HANDLE (DWORD)-10

The standard input device.

STD_OUTPUT_HANDLE (DWORD)-11

The standard output device.

STD_ERROR_HANDLE (DWORD)-12

The standard error device.

 

hHandle [in]
The handle for the standard device.

Return value

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.

Remarks

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.

Examples

For an example, see Creating a Child Process with Redirected Input and Output.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

Console Functions

Console Handles

CreateFile

GetStdHandle