0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cscの作法 その572

Posted at

概要

cscの作法、調べてみた。
練習問題やってみた。

練習問題

c#で、コンソールアプリの結果を取得せよ。

写真

image.png

サンプルコード

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;

class form1: Form {
	form1() {
		Text = "Checker";
		ClientSize = new Size(300, 300);
		Process process = new Process();
		process.StartInfo.FileName = "test1.exe";
		process.StartInfo.UseShellExecute = false;
		process.StartInfo.RedirectStandardOutput = true;
		process.EnableRaisingEvents = true;
		process.StartInfo.Arguments = "";
		process.Exited += (s, evt) => {
			process.Dispose();
		};
		process.OutputDataReceived += new DataReceivedEventHandler((_sender, _e) => {
			if (!String.IsNullOrEmpty(_e.Data))
			{
				Console.WriteLine(_e.Data);
				if (_e.Data == "1")
				{
					MessageBox.Show("hit!");
				}
			}
		});
		process.Start();
		process.BeginOutputReadLine();
	}
	[STAThread]
	public static void Main() {
		Application.Run(new form1());
	}
}

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?