console-application

What happens when you close a c++ console application

别说谁变了你拦得住时间么 提交于 2019-11-26 08:24:43
问题 I guess the question says it all, but, what happens if someone closes a c++ console app? As in, clicks the \"x\" in the top corner. Does it instantly close? Does it throw some sort of exception? Is it undefined behavior? 回答1: Closing a c++ console app with the "x" in the top corner throws an CTRL_CLOSE_EVENT which you could catch and process if you set a control handler using the SetConsoleCtrlHandler function. In there you could override the close functionality and perform whatever you

How can I write fast colored output to Console?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 07:58:17
问题 I want to learn if there is another ( faster ) way to output text to the console application window using C# .net than with the simple Write , BackgroundColor and ForegroundColor methods and properties? I learned that each cell has a background color and a foreground color, and I would like to cache/buffer/write faster than using the mentioned methods. Maybe there is some help using the Out buffer, but I don\'t know how to encode the colors into the stream, if that is where the color data

How to keep console window open

别说谁变了你拦得住时间么 提交于 2019-11-26 07:47:49
问题 When I run my program, the console window seems to run and close. How to keep it open so I can see the results? class Program { public class StringAddString { public virtual void AddString() { var strings2 = new string[] { \"1\", \"2\", \"3\", \"4\", \"5\",\"6\", \"7\", \"8\", \"9\"}; Console.WriteLine(strings2); Console.ReadLine(); } } static void Main(string[] args) { StringAddString s = new StringAddString(); } } 回答1: You forgot calling your method: static void Main(string[] args) {

C++ Detect when user presses arrow key

半城伤御伤魂 提交于 2019-11-26 07:43:35
问题 I have been having a problem with detecting arrow key presses in my C++ console application. I have tried everything I have found, both here and on other tutorial sites, but all of them give me the same thing whenever I press the arrow: Process returned 0 <0x0> execution time : 2.249 s Press any key to continue. Here are all the methods of detecting the key press that I have tried, all ending up the same way. These are the only two left in my code, the others I attempted I deleted instead of

How to programmatic disable C# Console Application&#39;s Quick Edit mode?

别等时光非礼了梦想. 提交于 2019-11-26 07:27:46
问题 I,ve tried several solutions found, like the one -> http://www.pcreview.co.uk/forums/console-writeline-hangs-if-user-click-into-console-window-t1412701.html But, i observed that mode in GetConsoleMode(IntPtr hConsoleHandle, out int mode) will be different for different console app. It is not constant. Can I disable mouse clicks (right/left buttons) on a console application to achieve the same scenario. I found that it can be done with IMessageFilter but only for Window Form Application and

How to stop C# console applications from closing automatically? [duplicate]

回眸只為那壹抹淺笑 提交于 2019-11-26 06:46:41
This question already has an answer here: Why is the console window closing immediately once displayed my output? 21 answers My console applications on Visual Studio are closing automatically, so I'd like to use something like C's system("PAUSE") to "pause" the applications at the end of its execution, how can I achieve that? Console.ReadLine(); or Console.ReadKey(); ReadLine() waits for ↩ , ReadKey() waits for any key (except for modifier keys). Edit: stole the key symbol from Darin. Silvia Z You can just compile (start debugging) your work with Ctrl + F5 . Try it. I always do it and the

Displaying Arabic characters in C# console application

可紊 提交于 2019-11-26 05:38:39
问题 I believe it was possible to show Arabic characters on a console application 13+ years ago, since the days of Windows ME. Now i am using Visual Studio 2013, On a Windows 8, and the following code shows: ????? ?? Console.OutputEncoding = System.Text.Encoding.Unicode; Console.WriteLine(\"مرحبا بك\"); Is there anyway to show Arabic characters in the console output? 回答1: There are several issues to resolve to get this to work. You need a font that supports both Arabic AND the windows console. See

Using ELMAH in a console application

白昼怎懂夜的黑 提交于 2019-11-26 05:16:08
问题 I just started using ELMAH and am a fan. My team supports a large number of web applications and I\'m particularly excited that ELMAH lets us save exceptions from each application to the same MS SQL database table. We also support a few console, DLL and desktop applications. Is it possible to use the ELMAH DLL to log exceptions in these apps to that same location? 回答1: We have exactly the same situation here. Running ELMAH for all our web applications. A few of them have console based

How to run a .NET console application in the background

☆樱花仙子☆ 提交于 2019-11-26 04:44:48
问题 I have a console application written in C# that is scheduled to run every 15 minutes or so using the built-in Windows Task Scheduler. Every time it runs, the black console box pops up for the duration of its execution and then closes. I am not writing anything to the console. Is there a way to make this run in the background? 回答1: Easy! It seems hard to believe, but it works as a charm. I have used this for some setup projects, when you want to perform custom tasks with no signs of it. Create

how to run a winform from console application?

六眼飞鱼酱① 提交于 2019-11-26 04:38:09
How do I create, execute and control a winform from within a console application? Marc Gravell The easiest option is to start a windows forms project, then change the output-type to Console Application. Alternatively, just add a reference to System.Windows.Forms.dll, and start coding: using System.Windows.Forms; [STAThread] static void Main() { Application.EnableVisualStyles(); Application.Run(new Form()); // or whatever } The important bit is the [STAThread] on your Main() method, required for full COM support. Tergiver I recently wanted to do this and found that I was not happy with any of