console-application

Compile Console App as 32 bit

余生颓废 提交于 2019-12-20 01:38:01
问题 I have a Windows Console Application that I need to compile as 32 bit. It's written in C# and I have all the Visual Studio 2012 updates. I've tried following several things on here, but I'm never given an option for 32 bit. How can I compile it as 32 bit? 回答1: With Visual Studio you are able to target what platform. By default it will run on "Any CPU" (read 32 or 64 bit), but you can specify if you desire. Look under Project>Properties>Build and look for the "Platform Target" property. 回答2:

How do I make an console application run until the user enters “Q”, “q”, “Quit” or “quit” to terminate it?

风格不统一 提交于 2019-12-20 01:34:47
问题 How do I make an console application run until the user enters "Q", "q", "Quit" or "quit" to terminate it? This is my current code: public class Class1 { [STAThread] static void Main(string[] args) { string userName; int i = 0, totalCal = 0, cal = 1; Console.WriteLine("Welcome to the magical calorie counter!"); Console.WriteLine(); Console.Write("Enter in your name -> "); userName = Console.ReadLine(); for (i = 0; i <= 10; i++) { Console.WriteLine("Hello {0}.....Let's add some calories!!",

C# library for more ConsoleColors? [duplicate]

元气小坏坏 提交于 2019-12-20 01:12:38
问题 This question already has answers here : redefining Console colour palette in c# (1 answer) Custom text color in C# console application? (10 answers) Closed 6 years ago . I have been writing console apps for a while and noticed that the consoles (such as cmd.exe) support RGB colors but the 'Console' class for .NET doesn't. Does anyone know of a library that would allow RGB colors for a console app in C#? 回答1: I have found a solution but it is not worth the time and effort, this should be

Why does Console.ReadKey() block output of Console.WriteLine called in another thread?

元气小坏坏 提交于 2019-12-19 18:55:41
问题 I have a very simple console app. static void Main(string[] args) { DoAsync(); Console.ReadKey(); } Here DoAsync starts set of task and returns not waiting for tasks' completition. Each task writes to Console, but the ouptut is not shown before key is pressed. When I use Console.ReadLine everything works fine. So I'm curious about ReadKey() pecularities. 回答1: From the documentation for Console.ReadKey() : The ReadKey method waits, that is, blocks on the thread issuing the ReadKey method,

User input without pausing code (c++ console application)

隐身守侯 提交于 2019-12-19 12:02:00
问题 How can I enter an input without causing the code to stop executing? I have been searching for an answer during the last 20 minutes without result. cin >> string; pauses the code AFAIK. Would I need to use mulithreading, or is there a better way? (I don't even know if multithreading would work.) I've recently started learning c++, I am a beginner to say the least, so please explain thoroughly and include any library I might need, thank you. 回答1: There are two algorithms for getting input

AttachConsole Error 5: Access is denied

假装没事ソ 提交于 2019-12-19 11:30:08
问题 I'm working with a C++ Console Application in Visual Studio 2013, working on Windows. First I detached the console using FreeConsole , it works; then, called AllocConsole as FreeConsole then AttachConsole not working suggested, returns true meaning success; last, I tried to attach it back using AttachConsole , but nothing happened -- #include <psapi.h> DWORD winpid = GetCurrentProcessId(); // get pid std::cout << winpid; // it works FreeConsole(); // console lost bool succeed = AllocConsole()

Console application starting another process environment variables not accessible

爱⌒轻易说出口 提交于 2019-12-19 10:48:13
问题 I have a VB6 executable which is accessing some system environment variables. I have implemented a .NET console application which checks if those environment variables exist, creates them if needed, and then runs the VB6 application by calling Process.Start . Doing this, the VB6 application cannot find the environment variables and it says they don't exist. If I run the VB6 application from Windows Explorer it works fine and can find the variables. So it seems the VB6 app is running under the

On Windows, how does console window ownership work?

流过昼夜 提交于 2019-12-19 08:06:45
问题 When a console application is started from another console application, how does console ownership work? I see four possibilities: The second application inherits the console from the first application for its lifetime, with the console returning to the original owner on exit. Each application has its own console. Windows then somehow merges the content of the two into what the "console" visible to the user The second application get a handle to the console that belongs to the first

Calling Environment.Exit() Within a Using Block

只愿长相守 提交于 2019-12-19 05:23:18
问题 If I have a console application with code like: using (DisposableObject object = new DisposableObject()) { if (a condition) Environment.Exit(0); // Do Stuff } Will my object be properly disposed? Or does the thread die before the object is cleaned up? 回答1: Your application will terminate and all managed memory will be released at that point. The generated finally block will not execute, so any Dispose methods will not be called, so any non-managed resources may very well not be released. See

How do I create a Resources file for a Console Application?

孤街浪徒 提交于 2019-12-19 05:20:17
问题 I'm trying to use an embedded resource in a console application, but apparently console applications don't come with a resource file automatically. How do I create a resources file for my console app? 回答1: The project template for a console mode application doesn't have pre-cooked Resources. You simply add it with Project + Properties, Resources tab, click the "Click here to create one" link. Take an hour and click around some more. This is all very discoverable but you have to take a look.