In addition, honour the maximum number of history buffers allowed when
creating new ones.
Some implementation information has been obtained from
https://github.com/microsoft/terminal
(under MIT License).
It retrieves the handle to the desktop assigned to the specified
thread belonging to a console application, which is going to be
where the input thread of this console is.