get_standard_handle


handle get_standard_handle(unsigned destination)

This function obtains the handle of a standard console file.

Parameters

unsigned destination

Specifies the standard file to be obtained.

Return

handle

-1 An error occurred.
Other The handle of the requested device.

Notes

Standard input returns the handle of the console's input buffer; whereas, standard output and standard error obtain the handle of the active screen buffer.

The functions read_file and write_file may be used on the file instances obtained through this function.

Unless otherwise changed (via function set_standard_handle), the handles returned by this function have access_type::generic_read and access_type::generic_write.

The function set_standard_handle may be used to redirect the standard input, output and error files; in which case, this function returns the redirected handles.

If standard input has been redirected, using "CONIN$" with function create_file obtains the handle of the console input buffer. If standard output has been redirected, using "CONOUT$" with function create_file obtains the handle of the console's screen buffer.