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