HANDLE CreateConsoleScreenBuffer(fdwDesiredAccess, fdwShareMode, lpsa, fdwType, pvReserved) | |||||
DWORD fdwDesiredAccess; | /* desired access to screen buffer | */ | |||
DWORD fdwShareMode; | /* specifies how buffer is shared | */ | |||
LPSECURITY_ATTRIBUTES lpsa; | /* optional security attributes | */ | |||
DWORD fdwType; | /* type of buffer to create | */ | |||
PVOID pvReserved; | /* should be NULL | */ |
The CreateConsoleScreenBuffer function creates a console screen buffer and returns a handle to it.
fdwDesiredAccess
Specifies the desired access to the console screen buffer. This parameter can be a combination of the following values:
Value | Meaning |
GENERIC_READ | Read access to the console screen buffer is requested. This allows data to be read from the console screen buffer. |
GENERIC_WRITE | Write access to the console screen buffer is requested. This allows data to be written to the console screen buffer. |
fdwShareMode
Specifies how this console screen buffer can be shared. This parameter can be a combination of the following values:
Value | Meaning |
0 | The console screen buffer cannot be shared. |
FILE_SHARE_READ | Other open operations may be performed on the console screen buffer for read access. |
FILE_SHARE_WRITE | Other open operations may be performed on the console screen buffer for write access. |
lpsa
Points to a SECURITY_ATTRIBUTES data structure that specifies the security attributes for the console screen buffer.
The SECURITY_ATTRIBUTES structure has the following format:
typedef struct _SECURITY_ATTRIBUTES { /* sa */
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES;
fdwType
Specifies the type of console screen buffer to create. The only currently supported screen-buffer type is CONSOLE_TEXTMODE_BUFFER.
pvReserved
Reserved for possible future use. Should be NULL.
If the function is successful, the return value is an open handle to the specified console screen buffer. Otherwise, it is INVALID_HANDLE_VALUE. Use the GetLastError function to obtain extended error information.
Depending on the access specified in the fdwDesiredAccess parameter, the screen buffer handle returned by this function can be used in any of the functions that read from or write to a console screen buffer. A console can have multiple screen buffers but only one active screen buffer. Inactive screen buffers can be accessed for reading and writing, but only the active screen buffer is displayed. Use SetConsoleActiveScreenBuffer to make this the active screen buffer
GetConsoleScreenBufferInfo, SetConsoleScreenBufferSize, SetConsoleActiveScreenBuffer, WriteFile, ReadConsoleOutput, WriteConsoleOutput