Invoke API Clear Screen

Source: Internet
Author: User

Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; Using system.runtime.interopservices;namespace calculate{struct Stdhandleenum {public const int Std_input_h        Andle =-10;        public const INT Std_output_handle =-11;    public const INT Std_error_handle =-12;    };            Static class Consoleex {internal struct COORD {public short X;        public short Y;            } [StructLayout (layoutkind.sequential, Pack = 1)] internal struct Console_screen_buffer_info {            Public COORD Size;            Public COORD p1;            public short A1;            public short W1;            public short W2;            public short W3;            public short W4;        Public COORD M1;        } [DllImport ("kernel32.dll")] public static extern int GetStdHandle (int nstdhandle); [DllImport ("kernel32.dll")] public static extern bool GetcoNsolescreenbufferinfo (int hconsoleoutput, out console_screen_buffer_info lpconsolescreenbufferinfo); [DllImport ("kernel32.dll")] public static extern bool SetConsoleCursorPosition (int hconsoleoutput, COORD Dwcursorpo        Sition); [DllImport ("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern bool FILLCONSOLEOUTPU        Tcharacter (int hconsoleoutput, short ccharacter, int. nlength, COORD Writecoord, out int lpnumberofcharswritten);            public static void Clear () {Console_screen_buffer_info csbi;            int hOut;            int charout;            COORD Home;            HOut = GetStdHandle (Stdhandleenum.std_output_handle);            Getconsolescreenbufferinfo (HOut, out CSBI);            home.x = 0;            home.y = 0; Fillconsoleoutputcharacter (HOut, (short) ", Csbi. size.x * Csbi.            Size.y, Home, out charout);        SetConsoleCursorPosition (HOut, Home); }    }}

Invoke API Clear Screen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.