Vous êtes sur la page 1sur 3

Console Functions #include <windows.

h>
The following functions are used to access a console. Function AddConsoleAlias AllocConsole AttachConsole CreateConsoleScreenBuffer FillConsoleOutputAttribute FillConsoleOutputCharacter FlushConsoleInputBuffer FreeConsole GenerateConsoleCtrlEvent GetConsoleAlias GetConsoleAliases GetConsoleAliasesLength GetConsoleAliasExes GetConsoleAliasExesLength GetConsoleCP GetConsoleCursorInfo GetConsoleDisplayMode GetConsoleFontSize GetConsoleMode GetConsoleOutputCP GetConsoleProcessList GetConsoleScreenBufferInfo GetConsoleSelectionInfo GetConsoleTitle GetConsoleWindow GetCurrentConsoleFont Description Defines a console alias for the specified executable. Allocates a new console for the calling process. Attaches the calling process to the console of the specified process. Creates a console screen buffer. Sets the text and background color attributes for a specified number of character cells. Writes a character to the console screen buffer a specified number of times. Flushes the console input buffer. Detaches the calling process from its console. Sends a specified signal to a console process group that shares the console associated with the calling process. Retrieves the specified alias for the specified executable. Retrieves all defined console aliases for the specified executable. Returns the size, in bytes, of the buffer needed to store all of the console aliases for the specified executable. Retrieves the names of all executables with console aliases defined. Returns the size, in bytes, of the buffer needed to store the names of all executables that have console aliases defined. Retrieves the input code page used by the console associated with the calling process. Retrieves information about the size and visibility of the cursor for the specified console screen buffer. Retrieves the display mode of the current console. Retrieves the size of the font used by the specified console screen buffer. Retrieves the current input mode of a console's input buffer or the current output mode of a console screen buffer. Retrieves the output code page used by the console associated with the calling process. Retrieves a list of the processes attached to the current console. Retrieves information about the specified console screen buffer. Retrieves information about the current console selection. Retrieves the title bar string for the current console window. Retrieves the window handle used by the console associated with the calling process. Retrieves information about the current console font.

GetLargestConsoleWindowSize GetNumberOfConsoleInputEvents GetNumberOfConsoleMouseButtons GetStdHandle HandlerRoutine PeekConsoleInput ReadConsole ReadConsoleInput ReadConsoleOutput ReadConsoleOutputAttribute ReadConsoleOutputCharacter ScrollConsoleScreenBuffer SetConsoleActiveScreenBuffer SetConsoleCP SetConsoleCtrlHandler SetConsoleCursorInfo SetConsoleCursorPosition SetConsoleDisplayMode SetConsoleMode SetConsoleOutputCP SetConsoleScreenBufferSize SetConsoleTextAttribute SetConsoleTitle SetConsoleWindowInfo SetStdHandle WriteConsole WriteConsoleInput

Retrieves the size of the largest possible console window. Retrieves the number of unread input records in the console's input buffer. Retrieves the number of buttons on the mouse used by the current console. Retrieves a handle for the standard input, standard output, or standard error device. An application-defined function used with the SetConsoleCtrlHandler function. Reads data from the specified console input buffer without removing it from the buffer. Reads character input from the console input buffer and removes it from the buffer. Reads data from a console input buffer and removes it from the buffer. Reads character and color attribute data from a rectangular block of character cells in a console screen buffer. Copies a specified number of foreground and background color attributes from consecutive cells of a console screen buffer. Copies a number of characters from consecutive cells of a console screen buffer. Moves a block of data in a screen buffer. Sets the specified screen buffer to be the currently displayed console screen buffer. Sets the input code page used by the console associated with the calling process. Adds or removes an application-defined HandlerRoutine from the list of handler functions for the calling process. Sets the size and visibility of the cursor for the specified console screen buffer. Sets the cursor position in the specified console screen buffer. Sets the display mode of the specified console screen buffer. Sets the input mode of a console's input buffer or the output mode of a console screen buffer. Sets the output code page used by the console associated with the calling process. Changes the size of the specified console screen buffer. Sets the foreground (text) and background color attributes of characters written to the console screen buffer. Sets the title bar string for the current console window. Sets the current size and position of a console screen buffer's window. Sets the handle for the standard input, standard output, or standard error device. Writes a character string to a console screen buffer beginning at the current cursor location. Writes data directly to the console input buffer.

WriteConsoleOutput WriteConsoleOutputAttribute WriteConsoleOutputCharacter

Writes character and color attribute data to a specified rectangular block of character cells in a console screen buffer. Copies a number of foreground and background color attributes to consecutive cells of a console screen buffer. Copies a number of characters to consecutive cells of a console screen buffer.

#include <iostream.h> #include <conio.h> #include <windows.h> void gotoxy(int x, int y) { HANDLE hCon; COORD dwPos; dwPos.X = x; dwPos.Y = y; hCon = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hCon,dwPos); } void clrscr(void) { HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); COORD coordScreen={0,0};//position that will occupy cursor DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi;//to obtain information from buffer DWORD dwConSize;//number of character cells from buffer //to obtain the total number of character cells from the current buffer GetConsoleScreenBufferInfo(hCon, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y;//rows by columns //To fill the whole screen with the character ' ' FillConsoleOutputCharacter(hCon,(TCHAR)' ',dwConSize, coordScreen,&cCharsWritten); //To obtain the present attribute of text GetConsoleScreenBufferInfo(hCon, &csbi); //Now, to place te attribute of buffer corresponding FillConsoleOutputAttribute(hCon,csbi.wAttributes,dwConSize, coordScreen,&cCharsWritten); //To put the cursor in the position (0,0) - top left cornerSetConsoleCursorPosition(hCon,coordScreen); return; } void main() { GetConsoleTitle("Hola",4); clrscr(); gotoxy(30,10); cout << "hola" << endl; getch(); }

Vous aimerez peut-être aussi