Skip to content

Latest commit

 

History

History
87 lines (64 loc) · 3.05 KB

allocconsole.md

File metadata and controls

87 lines (64 loc) · 3.05 KB
title description author ms.author ms.topic keywords f1_keywords MS-HAID MSHAttr ms.assetid topic_type api_name api_location api_type ms.localizationpriority
AllocConsole function
See reference information about the AllocConsole function, which allocates a new console for the calling process.
miniksa
miniksa
article
console, character mode applications, command line applications, terminal applications, console api
consoleapi/AllocConsole
wincon/AllocConsole
AllocConsole
\_win32\_allocconsole
base.allocconsole
consoles.allocconsole
PreferredSiteName:MSDN
PreferredLib:/library/windows/desktop
bdf3bf2f-8eb8-4ba6-bf3a-a67b29dffda2
apiref
AllocConsole
Kernel32.dll
API-MS-Win-Core-Console-l1-1-0.dll
KernelBase.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
DllExport
high

AllocConsole function

Allocates a new console for the calling process.

Syntax

BOOL WINAPI AllocConsole(void);

Parameters

This function has no parameters.

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

A process can be associated with only one console, so the AllocConsole function fails if the calling process already has a console. A process can use the FreeConsole function to detach itself from its current console, then it can call AllocConsole to create a new console or AttachConsole to attach to another console.

If the calling process creates a child process, the child inherits the new console.

AllocConsole initializes standard input, standard output, and standard error handles for the new console. The standard input handle is a handle to the console's input buffer, and the standard output and standard error handles are handles to the console's screen buffer. To retrieve these handles, use the GetStdHandle function.

This function is primarily used by a graphical user interface (GUI) application to create a console window. GUI applications are initialized without a console. Console applications are initialized with a console, unless they are created as detached processes (by calling the CreateProcess function with the DETACHED_PROCESS flag).

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Header ConsoleApi.h (via WinCon.h, include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

Console Functions

Consoles

AttachConsole

CreateProcess

FreeConsole

GetStdHandle