console-application

C++ Prevent the console window from closing when red X is clicked

╄→尐↘猪︶ㄣ 提交于 2019-12-06 09:55:17
问题 I'm developing a simple C++ console application without classes & objects. Is there any method or function to prevent the console from closing when red X button is clicked ? I'm using Visual Studio C++ Express 2010 : A simple console application which containes only main.cpp file. Thank you for answering my question :) !! 回答1: This worked for me: #include "conio.h" void main() { HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMenu(hwnd, FALSE); EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED

SetConsoleActiveScreenBuffer does not display screen buffer

戏子无情 提交于 2019-12-06 09:13:44
问题 I am currently trying to write a console application in C# with two screen buffers, which should be swapped back and forth (much like VSync on a modern GPU). Since the System.Console class does not provide a way to switch buffers, I had to P/Invoke several methods from kernel32.dll. This is my current code, grossly simplified: static void Main(string[] args) { IntPtr oldBuffer = GetStdHandle(-11); //Gets the handle for the default console buffer IntPtr newBuffer = CreateConsoleScreenBuffer(0,

Reading file, and monitor new line

£可爱£侵袭症+ 提交于 2019-12-06 09:06:11
问题 I'm looking to create a console application that will read a file, and monitor every new line since it's being write by another process every .5 seconds. How can I achieve that, within a Console App using .NET 4.5? 回答1: As @Sudhakar mentioned, FileSystemWatcher is useful when you want to be notified when a file updates sporadically, and polling at regular intervals is useful when you want to be constantly processing information from an always-growing file (such as a busy log file). I'd like

Unit Testing a Console Application inside Visual Studio

独自空忆成欢 提交于 2019-12-06 08:51:02
问题 I have a Test Project in Visual Studio I'd like to use to test my console application with (in the same solution). I'm trying to set up tests which call the console app with specific parameters, and compare the actual output with what I expect, then do my usual Assert statements to appropriately pass/fail the test. The best way to do this, that I can come up with, is to execute the app exe with System.Diagnostics.Process inside the unit test. This works. I can read the output, and all is well

How do I return a value from a console application to a service in .NET?

本秂侑毒 提交于 2019-12-06 08:42:59
问题 I have a .NET service. I have a .NET console application. I want something along the lines of the service calling Process.Start("consoleapp.exe") and getting some information returned back from the app, ideally just returning a number. How do I do this? Edit: I figure it must be: Process.Start("myapp.exe").ExitCode - but how do I set the exit code in the console app? 回答1: Process p = Process.Start("app.exe"); p.WaitForExit(); int number = p.ExitCode; And in app.exe you set Enviroment.ExitCode

Colored console output in Linux

ε祈祈猫儿з 提交于 2019-12-06 07:38:13
问题 I just started learning programming in C. the first problem was to choose on which platform should I learn it, and I selected Ubuntu. I found a GCC compiler to compile my projects, and it worked fine for me. I was running my compiled projects through Terminal. But when I wanted to write a program which have to show a text on a colorful background, I understood that Terminal is not helping me. Actually I am learning from lessons written for programming on Windows, and they use there Borland C+

Generating .NET Core Console App .exe in Visual Studio 2017

蹲街弑〆低调 提交于 2019-12-06 07:16:57
(I am using Visual Studio 2017) I started a small console application (I created a .NET Core application), then I wanted to build the .exe file. But all I get is .dll files and there isn't any .exe file. Can you help me please ? what do I change in Visual Studios settings, to have an .exe file in my correct directory for my console application? In fact .NET Core by default generates only dll files that can be run with dotnet : dotnet myapp.dll If you want to publish the app as a self-contained exe , you have to right-click the project in Solution Explorer , select Publish and then choose the

Console Application - Unable to find a version of the runtime to run this application (and I have them all)

只愿长相守 提交于 2019-12-06 06:59:32
问题 Like others, I'm having an issue with a simple console application that reads records from our database. This small program needs to sit on our file server. It reads new records and forwards a summary off to the parent company. This is going to be a scheduled task that runs every X minutes. I do NOT want an Installer, because I don't want the server to require a reboot. From the screenshot, notice I have almost all versions of the framework already installed and that the debug information is

log4net console app not logging on publish

£可爱£侵袭症+ 提交于 2019-12-06 06:35:47
问题 I have a console app using log4net (via Castle Windsor). Everything logs fine to the console when I debug, but when I publish and run the app, nothing is logged. I have my log4net configuration in a separate file (log4net.config). I'm thinking it's not finding the config file, but that's just a guess. I'm a web dev and haven't deployed many console apps. Am I missing something? Do I need to manually copy the log4net.config file to the exe directory? I'm on VS2010. app.config: <?xml version="1

C# - Console Keystrokes

[亡魂溺海] 提交于 2019-12-06 05:43:35
I want to compare the key pressed in a console to the left arrow key if they are equal meaning the key pressed was the left arrow key, key change the background color of the console to cyan... I'm not sure how to set up the If statement though, because I dont know how to compare keys in a console. using System; namespace ConsolePaint { class MainClass { public static void Main (string[] args) { ConsoleKeyInfo keypress; keypress = Console.ReadKey(); // read keystrokes if ( keypress.KeyChar == ConsoleKey.LeftArrow ) { Console.BackgroundColor = "Cyan"; } } } } try this: ConsoleKeyInfo keypress;