How to customize the console Applicaton

Source: Internet
Author: User

Here's the code to maximize the console and change the color of the font it displays, including the timing code (to help with profiling):

    classProgram {[DllImport ("Kernel32.dll", exactspelling =true)]        Private Static externIntPtr Getconsolewindow (); Private StaticIntPtr Thisconsole =Getconsolewindow (); [DllImport ("user32.dll", CharSet = CharSet.Auto, SetLastError =true)]        Private Static extern BOOLShowWindow (IntPtr hWnd,intncmdshow); Private Const intHIDE =0; Private Const intmaximize =3; Private Const intMINIMIZE =6; Private Const intRESTORE =9; Private Const intOldestphaseno =2003001; Static voidMain (string[] args) {            //Set Maximum console windows sizeconsole.setwindowsize (Console.largestwindowwidth, console.largestwindowheight);            ShowWindow (Thisconsole, maximize); //Start the time watchStopwatch Watch =NewStopwatch (); Watch.                        Start (); //Stop the time Wattchdictionary<string,string> ssqrecords =getssqiurecords ().            Result; Watch.            Stop (); //Change/set the console ' s Foregound clodr as GreenConsole.foregroundcolor =Consolecolor.green; Console.WriteLine (watch.            Elapsed.totalseconds); //Restart The time calculation to 0Watch.            Restart ();            Savelotterydatatolocalconfig (ssqrecords); Watch.            Stop (); Console.WriteLine (watch.            Elapsed.totalseconds); //Revert back to the default colorConsole.foregroundcolor =Consolecolor.gray; //Set the Display buffer for console windowConsole.setbuffersize ( +,30000); }    }

How to customize the console Applicaton

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.