console-application

Opening a TStream on stdin/stdout in a Delphi console app

扶醉桌前 提交于 2019-12-18 10:09:29
问题 I'm trying to write a Delphi console application that creates a TStream for its standard input, and another TStream for its standard output. (It will be launched by a host app with its input and output redirected to pipes, and will be passing binary data to/from that host app, so TStream will be much better-suited to the task than ReadLn/WriteLn.) How do I go about opening a TStream on standard input or standard output? 回答1: Off the top of my head: InputStream := THandleStream.Create

How can I limit the number of characters for a console input? C#

非 Y 不嫁゛ 提交于 2019-12-18 09:47:14
问题 Basically I want 200 characters maximum to come up in Console.ReadLine() for user input before characters start being suppressed. I want it like TextBox.MaxLength except for console input. How would I go about this? And I don't want to do input.Substring(0, 200). Solved: I used my own ReadLine function which was a loop of Console.ReadKey(). It looks like this, essentially: StringBuilder sb = new StringBuilder(); bool loop = true; while (loop) { ConsoleKeyInfo keyInfo = Console.ReadKey(true);

'AttributeError' while trying to create a console screen using urwid

陌路散爱 提交于 2019-12-18 09:45:37
问题 code below creates a layout and displays some text in the layout. Next the layout is displayed on the console screen using raw display module from urwid library. (More info on my complete project can be gleaned from questions at widget advice for a console project and urwid for a console project. My skype help request being here.) However running the code fails as an AttributeError is raised as described below. On looking at source code for urwid at /usr/lib64/python2.7/site-packages/urwid I

BYTE as undeclared identifier even though I have included windows.h

梦想的初衷 提交于 2019-12-18 09:33:08
问题 My code is as follows // ConsoleApplication1.cpp : Defines the entry point for the console application. // #include <windows.h> #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { BYTE* pAlloc1 = NULL; return 0; } creating following errors. error C2065: 'BYTE' : undeclared identifier What am I doing wrong here? 回答1: You have #include "stdafx.h" , which usually means that you're using a precompiled header. If you use a precompiled header, anything preceding the precompiled header will

Capturing an c# executable output from another C# program

有些话、适合烂在心里 提交于 2019-12-18 08:54:54
问题 I am executing a C# program i.e a .exe from another C# program. but the .exe has some Console.WriteLine() in its program. I want to get the standard output into my C# program. for example, Consider a C# executable i.e 1.exe and there is another Program 2.cs. I am calling from 2.cs 1.exe. Now there is some output that the console is displaying from 1. exe. But I want the ouput in my program 2.cs. for displaying information to user. Is it possible? Please help Thanks Sai sindhu 回答1: You can use

smtp exception “failure sending mail”

感情迁移 提交于 2019-12-18 08:25:49
问题 I created console application for sending Email public static void sendEmail(string email, string body) { if (String.IsNullOrEmpty(email)) return; try { MailMessage mail = new MailMessage(); mail.To.Add(email); mail.From = new MailAddress("test@gmail.com"); mail.Subject = "sub"; mail.Body = body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address smtp.Credentials = new System.Net.NetworkCredential("test@gmail.com", "admin

How can I detect if “Press any key to continue . . .” will be displayed?

与世无争的帅哥 提交于 2019-12-18 07:39:41
问题 When running a console application in Visual Studio, depending on your settings, it will add a prompt after the program exits: Press any key to continue . . . I have found how to detect if I am running under the debugger(use Debugger.IsAttached ), but it isn't helpful. Press CTRL-F5 to Start Without Debugging sets this flag to false , yet still shows the prompt . I want to detect this because I'd like to display my own message and wait for a keypress, but not double up keypress checks . I don

How to set console cursor position for stdout

二次信任 提交于 2019-12-18 07:03:17
问题 I want to set cursor position to print a char on console screen. Is there a solution without using ncurses library. Is there an equivalent call for SetConsoleCursorPosition in Linux from example below: void print (int x, int y, char c) { COORD p = { x, y }; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), p); printf("%c", c); } 回答1: Perhaps a little history is in order. What you call the “console” in Windows is really an example of a terminal emulator; however, unlike traditional

Windows console application - signal for closing event

♀尐吖头ヾ 提交于 2019-12-18 06:56:29
问题 In windows console application, one can catch pressing ctrl+c by using: #include <stdio.h> #include <signal.h> void SigInt_Handler(int n_signal) { printf("interrupted\n"); } int main(int n_arg_num, const char **p_arg_list) { signal(SIGINT, &SigInt_Handler); getchar(); // wait for user intervention } This works well, except it does not work at all if the user presses the cross × that closes the console window. Is there any signal for that? The reason I need this is I have this CUDA application

Show message Box in .net console application

前提是你 提交于 2019-12-18 03:57:46
问题 How to show a message box in a .net c# or vb console application ? Something like: Console.WriteLine("Hello World"); MessageBox.Show("Hello World"); or Console.WriteLine("Hello") MsgBox("Hello") in c# and vb respectively. Is it possible? 回答1: We can show a message box in a console application. But first include this reference in your vb.net or c# console application System.Windows.Forms; Reference: To add reference in vb.net program right click (in solution explorer) on your project name->