console-application

How do I print UTF-8 from c++ console application on Windows

早过忘川 提交于 2019-11-26 04:25:00
问题 For a C++ console application compiled with Visual Studio 2008 on English Windows (XP,Vista or 7). Is it possible to print out to the console and correctly display UTF-8 encoded Japanese using cout or wcout? 回答1: The Windows console uses the OEM code page by default to display output. To change the code page to Unicode enter chcp 65001 in the console, or try to change the code page programmatically with SetConsoleOutputCP. Note that you probably have to change the font of the console to one

.NET Console Application Exit Event

邮差的信 提交于 2019-11-26 04:22:22
In .NET, is there a method, such as an event, for detecting when a Console Application is exiting? I need to clean up some threads and COM objects. I am running a message loop, without a form, from the console application. A DCOM component that I am using seems to require that the application pump messages. I have tried adding a handler to Process.GetCurrentProcess.Exited and Process.GetCurrentProcess.Disposed. I have also tried adding a handler to Application.ApplicationExit and Application.ThreadExit events, but they are not firing. Perhaps that is because I am not using a form. You can use

Custom text color in C# console application?

天涯浪子 提交于 2019-11-26 03:57:37
问题 I just finished my C# console application code for a project and would like to add some color to my font. I would love to be able to use a custom color - orange. Is there any way to do this? This is the code I have been using to change colors in the past, but it doesn\'t offer orange: Console.ForegroundColor = ConsoleColor.Magenta(and so on); Is there a way to maybe insert a hex value for the color or something similar? 回答1: The list found at http://msdn.microsoft.com/en-us/library/system

.NET console application as Windows service

旧巷老猫 提交于 2019-11-26 03:47:41
问题 I have console application and would like to run it as Windows service. VS2010 has project template which allow to attach console project and build Windows service. I would like to not add separated service project and if possible integrate service code into console application to keep console application as one project which could run as console application or as windows service if run for example from command line using switches. Maybe someone could suggest class library or code snippet

How to run a C# console application with the console hidden

不羁的心 提交于 2019-11-26 03:32:38
问题 Is there a way to hide the console window when executing a console application? I am currently using a Windows Forms application to start a console process, but I don\'t want the console window to be displayed while the task is running. 回答1: If you are using the ProcessStartInfo class you can set the window style to hidden - in the case of console (not GUI) applications, you have to set CreateNoWindow to true : System.Diagnostics.ProcessStartInfo start = new System.Diagnostics

Could not load file or assembly … An attempt was made to load a program with an incorrect format (System.BadImageFormatException)

寵の児 提交于 2019-11-26 03:16:27
问题 I have two projects, ProjectA and ProjectB . ProjectB is a console application, which depends on ProjectA . Yesterday, everything was working fine, but suddenly today when I run ProjectB I get this: BadImageFormatException was unhandled : Could not load file or assembly \'ProjectA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\' or one of its dependencies. An attempt was made to load a program with an incorrect format. Both are just regular projects, with no dependencies on any other

Can't specify the 'async' modifier on the 'Main' method of a console app

半腔热情 提交于 2019-11-26 03:12:44
问题 I am new to asynchronous programming with the async modifier. I am trying to figure out how to make sure that my Main method of a console application actually runs asynchronously. class Program { static void Main(string[] args) { Bootstrapper bs = new Bootstrapper(); var list = bs.GetList(); } } public class Bootstrapper { public async Task<List<TvChannel>> GetList() { GetPrograms pro = new GetPrograms(); return await pro.DownloadTvChannels(); } } I know this is not running asynchronously

Java gotoxy(x,y) for console applications

给你一囗甜甜゛ 提交于 2019-11-26 02:57:09
问题 I\'m writing a simple console application (80x24) in Java, is there a gotoxy(x,y) equivalent? 回答1: If by gotoxy(x,y), you want to reposition your cursor somewhere specific on the console, you can usually use VT100 control codes to do this. See http://www.termsys.demon.co.uk/vtansi.htm. Do something like char escCode = 0x1B; int row = 10; int column = 10; System.out.print(String.format("%c[%d;%df",escCode,row,column)); Which should move the cursor to position 10,10 on the console. 回答2: I don't

Global hotkey in console application

会有一股神秘感。 提交于 2019-11-26 02:35:33
问题 Does anyone know how to use the RegisterHotKey/UnregisterHotKey API calls in a console application? I assume that setting up/removing the hotkey is the same, but how do I get the call back when the key was pressed? Every example I see is for Winforms, and uses protected override void WndProc(ref Message m){...} , which isn\'t available to me. update: what I have is below, but the event is never hit. I thought it could be because when you load ConsoleShell it does block further execution, but

Masking password input from the console : Java

心不动则不痛 提交于 2019-11-26 02:07:37
How to mask a password from console input? I'm using Java 6. I've tried using console.readPassword() , but it wouldn't work. A full example might help me actually. Here's my code: import java.io.BufferedReader; import java.io.Console; import java.io.IOException; import java.io.InputStreamReader; public class Test { public static void main(String[] args) { Console console = System.console(); console.printf("Please enter your username: "); String username = console.readLine(); console.printf(username + "\n"); console.printf("Please enter your password: "); char[] passwordChars = console