console functions

Upload: jorgekf13

Post on 05-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Console Functions

    1/3

    Console Functions

    #include

    The following functions are used to access a console.

    Function Description

    AddConsoleAlias Defines a console alias for the specified executable.

    AllocConsole Allocates a new console for the calling process.

    AttachConsoleAttaches the calling process to the console of the specifiedprocess.

    CreateConsoleScreenBuffer Creates a console screen buffer.

    FillConsoleOutputAttributeSets the text and background color attributes for a specified

    number of character cells.

    FillConsoleOutputCharacterWrites a character to the console screen buffer a specified

    number of times.

    FlushConsoleInputBuffer Flushes the console input buffer.

    FreeConsole Detaches the calling process from its console.

    GenerateConsoleCtrlEventSends a specified signal to a console process group that shares

    the console associated with the calling process.

    GetConsoleAlias Retrieves the specified alias for the specified executable.

    GetConsoleAliases Retrieves all defined console aliases for the specified executable.

    GetConsoleAliasesLengthReturns the size, in bytes, of the buffer needed to store all of

    the console aliases for the specified executable.

    GetConsoleAliasExes

    Retrieves the names of all executables with console aliases

    defined.

    GetConsoleAliasExesLengthReturns the size, in bytes, of the buffer needed to store the

    names of all executables that have console aliases defined.

    GetConsoleCPRetrieves the input code page used by the console associated

    with the calling process.

    GetConsoleCursorInfoRetrieves information about the size and visibility of the cursor

    for the specified console screen buffer.

    GetConsoleDisplayMode Retrieves the display mode of the current console.

    GetConsoleFontSizeRetrieves the size of the font used by the specified console

    screen buffer.

    GetConsoleModeRetrieves the current input mode of a console's input buffer orthe current output mode of a console screen buffer.

    GetConsoleOutputCPRetrieves the output code page used by the console associatedwith the calling process.

    GetConsoleProcessList Retrieves a list of the processes attached to the current console.

    GetConsoleScreenBufferInfo Retrieves information about the specified console screen buffer.

    GetConsoleSelectionInfo Retrieves information about the current console selection.

    GetConsoleTitle Retrieves the title bar string for the current console window.

    GetConsoleWindowRetrieves the window handle used by the console associated

    with the calling process.

    GetCurrentConsoleFont Retrieves information about the current console font.

    http://msdn.microsoft.com/library/en-us/dllproc/base/addconsolealias.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/allocconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/attachconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/createconsolescreenbuffer.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/fillconsoleoutputattribute.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/fillconsoleoutputcharacter.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/flushconsoleinputbuffer.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/freeconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/generateconsolectrlevent.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealias.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealiases.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealiaseslength.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealiasexes.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealiasexeslength.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolecp.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolecursorinfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoledisplaymode.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolefontsize.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolemode.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoleoutputcp.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoleprocesslist.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolescreenbufferinfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoleselectioninfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoletitle.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolewindow.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getcurrentconsolefont.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/allocconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/attachconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/createconsolescreenbuffer.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/fillconsoleoutputattribute.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/fillconsoleoutputcharacter.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/flushconsoleinputbuffer.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/freeconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/generateconsolectrlevent.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealias.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealiases.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealiaseslength.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealiasexes.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolealiasexeslength.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolecp.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolecursorinfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoledisplaymode.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolefontsize.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolemode.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoleoutputcp.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoleprocesslist.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolescreenbufferinfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoleselectioninfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsoletitle.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getconsolewindow.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getcurrentconsolefont.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/addconsolealias.asp
  • 7/31/2019 Console Functions

    2/3

    GetLargestConsoleWindowSize Retrieves the size of the largest possible console window.

    GetNumberOfConsoleInputEventsRetrieves the number of unread input records in the console's

    input buffer.

    GetNumberOfConsoleMouseButtonsRetrieves the number of buttons on the mouse used by thecurrent console.

    GetStdHandleRetrieves a handle for the standard input, standard output, or

    standard error device.

    HandlerRoutineAn application-defined function used with the

    SetConsoleCtrlHandler function.

    PeekConsoleInputReads data from the specified console input buffer withoutremoving it from the buffer.

    ReadConsoleReads character input from the console input buffer andremoves it from the buffer.

    ReadConsoleInputReads data from a console input buffer and removes it from the

    buffer.

    ReadConsoleOutput Reads character and color attribute data from a rectangularblock of character cells in a console screen buffer.

    ReadConsoleOutputAttributeCopies a specified number of foreground and background colorattributes from consecutive cells of a console screen buffer.

    ReadConsoleOutputCharacterCopies a number of characters from consecutive cells of aconsole screen buffer.

    ScrollConsoleScreenBuffer Moves a block of data in a screen buffer.

    SetConsoleActiveScreenBufferSets the specified screen buffer to be the currently displayed

    console screen buffer.

    SetConsoleCPSets the input code page used by the console associated with

    the calling process.

    SetConsoleCtrlHandlerAdds or removes an application-definedHandlerRoutine from

    the list of handler functions for the calling process.

    SetConsoleCursorInfoSets the size and visibility of the cursor for the specified console

    screen buffer.

    SetConsoleCursorPosition Sets the cursor position in the specified console screen buffer.

    SetConsoleDisplayMode Sets the display mode of the specified console screen buffer.

    SetConsoleModeSets the input mode of a console's input buffer or the output

    mode of a console screen buffer.

    SetConsoleOutputCPSets the output code page used by the console associated with

    the calling process.

    SetConsoleScreenBufferSize Changes the size of the specified console screen buffer.

    SetConsoleTextAttributeSets the foreground (text) and background color attributes of

    characters written to the console screen buffer.

    SetConsoleTitle Sets the title bar string for the current console window.

    SetConsoleWindowInfoSets the current size and position of a console screen buffer's

    window.

    SetStdHandleSets the handle for the standard input, standard output, or

    standard error device.

    WriteConsoleWrites a character string to a console screen buffer beginning at

    the current cursor location.

    WriteConsoleInput Writes data directly to the console input buffer.

    http://msdn.microsoft.com/library/en-us/dllproc/base/getlargestconsolewindowsize.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getnumberofconsoleinputevents.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getnumberofconsolemousebuttons.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getstdhandle.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/handlerroutine.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolectrlhandler.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/peekconsoleinput.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsoleinput.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsoleoutput.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsoleoutputattribute.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsoleoutputcharacter.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/scrollconsolescreenbuffer.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoleactivescreenbuffer.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolecp.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolectrlhandler.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/handlerroutine.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/handlerroutine.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolecursorinfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolecursorposition.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoledisplaymode.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolemode.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoleoutputcp.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolescreenbuffersize.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoletextattribute.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoletitle.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolewindowinfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setstdhandle.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/writeconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/writeconsoleinput.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getlargestconsolewindowsize.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getnumberofconsoleinputevents.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getnumberofconsolemousebuttons.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/getstdhandle.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/handlerroutine.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolectrlhandler.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/peekconsoleinput.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsoleinput.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsoleoutput.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsoleoutputattribute.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/readconsoleoutputcharacter.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/scrollconsolescreenbuffer.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoleactivescreenbuffer.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolecp.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolectrlhandler.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/handlerroutine.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolecursorinfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolecursorposition.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoledisplaymode.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolemode.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoleoutputcp.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolescreenbuffersize.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoletextattribute.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsoletitle.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setconsolewindowinfo.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/setstdhandle.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/writeconsole.asphttp://msdn.microsoft.com/library/en-us/dllproc/base/writeconsoleinput.asp
  • 7/31/2019 Console Functions

    3/3

    WriteConsoleOutputWrites character and color attribute data to a specified

    rectangular block of character cells in a console screen buffer.

    WriteConsoleOutputAttributeCopies a number of foreground and background color attributes

    to consecutive cells of a console screen buffer.

    WriteConsoleOutputCharacterCopies a number of characters to consecutive cells of a console

    screen buffer.

    #include

    #include

    #include

    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 bufferGetConsoleScreenBufferInfo(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 corner-SetConsoleCursorPosition(hCon,coordScreen);

    return;

    }

    void main()

    {

    GetConsoleTitle("Hola",4);

    clrscr();

    gotoxy(30,10);

    cout