console-application

how to bind a windows console application with java application?

痞子三分冷 提交于 2019-12-29 07:17:02
问题 i have an executable program (.exe) writen in c++ and run on windows console and i have a java swing applecation , so i want my java application to interact with the console app (send input and get output) . but how to do that ? 回答1: You can do it this way // Create the proccess in JAVA Process proc = Runtime.getRuntime().exec("Name of application"); // Receive outputs from another program inside Java by a stream InputStream ips = proc.getInputStream(); // Using the stream to get the messages

Wrapping a C# service in a console app to debug it

ⅰ亾dé卋堺 提交于 2019-12-29 04:29:07
问题 I want to debug a service written in C# and the old fashioned way is just too long. I have to stop the service, start my application that uses the service in debug mode (Visual studio 2008), start the service, attach to the service process and then navigate in my Asp.Net application to trigger the service. I basically have the service running in the background, waiting for a task. The web application will trigger a task to be picked up by the service. What I would like to do is to have a

How to receive messages using a message-only window in a console application?

最后都变了- 提交于 2019-12-29 04:23:15
问题 I've created a simple Win32 console application that creates a hidden message-only window and waits for messages, the full code is below. #include <iostream> #include <Windows.h> namespace { LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_COPYDATA) std::cout << "Got a message!" << std::endl; return DefWindowProc(hWnd, uMsg, wParam, lParam); } } int main() { WNDCLASS windowClass = {}; windowClass.lpfnWndProc = WindowProcedure; LPCWSTR

run console application in C# with parameters

自闭症网瘾萝莉.ら 提交于 2019-12-29 01:33:10
问题 How can I run a console application in C#, passing parameters to it, and get the result of the application in Unicode? Console.WriteLine is used in the console application. Important point is write Unicode in Console Application. 回答1: Sample from MSDN // Start the child process. Process p = new Process(); // Redirect the output stream of the child process. p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "Write500Lines.exe"; p.Start(); //

How do I use command line arguments in my C# console app?

核能气质少年 提交于 2019-12-28 17:55:49
问题 I am writing a url shortener app and I would like to also create a console app with C# to push the URLs to a WCF service which I have also created. WCF app will shorten the url on this URI; http://example.com/shorten/http://exaple.com so what I want is just that. My console exe file will be sitting inside c:\dev folder and on Windows command line, I would like to do this; c:\dev>myapp -throw http://example.com with this method I would like to talk to that service. there is no problem on

Is there a way to delete a character that has just been written using Console.WriteLine?

拜拜、爱过 提交于 2019-12-28 08:07:40
问题 Is there any way to delete the last character from the console, i.e. Console.WriteLine("List: apple,pear,"); // Somehow delete the last ',' character from the console. Console.WriteLine("."); // Now the console contains "List: apple,pear." Sure, I could create a string first then print that to the console, but I'm just curious to see if I can delete characters directly from the console. 回答1: "\b" is ASCII backspace. Print it to back up one char. Console.Write("Abc"); Console.Write("\b");

Edit text in C# console application? [duplicate]

微笑、不失礼 提交于 2019-12-28 04:23:15
问题 This question already has answers here : C# Advanced Console I/O [duplicate] (4 answers) Console.ReadLine(“Default Text Editable Text On Line”) (2 answers) Closed last year . Is there a way to edit text in a C# console application? In other words, is it possible to place pre-defined text on the command line so that the user can modify the text and then re-submit it to the app? 回答1: One thing that came to my mind is to...simulate keystrokes. And a simple example using SendKeys: static void

.NET Console TextWriter that Understands Indent/Unindent/IndentLevel

北慕城南 提交于 2019-12-28 03:10:34
问题 Does anybody have or know of a TextWriter for the Console that understand how to indent/unindent and has the ability to set the indent level. 回答1: Try this: class MyConsole : TextWriter { TextWriter mOldConsole; bool mDoIndent; public MyConsole() { mOldConsole = Console.Out; Console.SetOut(this); } public int Indent { get; set; } public override void Write(char ch) { if (mDoIndent) { mDoIndent = false; for (int ix = 0; ix < Indent; ++ix) mOldConsole.Write(" "); } mOldConsole.Write(ch); if (ch

How to navigate a few folders up?

江枫思渺然 提交于 2019-12-28 02:28:13
问题 One option would be to do System.IO.Directory.GetParent() a few times. Is there a more graceful way of travelling a few folders up from where the executing assembly resides? What I trying to do is to find a text file that resides one folder above the application folder. But the assembly itself is inside the bin, which is a few folders deep in the application folder. 回答1: Other simple way is to do this: string path = @"C:\Folder1\Folder2\Folder3\Folder4"; string newPath = Path.GetFullPath(Path

How do I only allow number input into my C# Console Application?

纵饮孤独 提交于 2019-12-28 02:07:46
问题 Console.WriteLine("Enter the cost of the item"); string input = Console.ReadLine(); double price = Convert.ToDouble(input); Hello, I want the keyboard buttons, A-Z, brackets, question mark, etc to be disabled. I want it so if you type it in, it will not show up in the Console. I only want the numbers 1-9 to show up. This is in C# Console application. Thanks for the help! 回答1: try this code snippet string _val = ""; Console.Write("Enter your value: "); ConsoleKeyInfo key; do { key = Console