using
System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ProcessSample
... {
/**//// <summary>
/// Form1 の概要の説明です。
/// </summary>
public class Form1 : System.Windows.Forms.Form
...{
private System.Windows.Forms.Button button1;
/**//// <summary>
/// 必要なデザイナ変数です。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
...{
//
// Windows フォーム デザイナ サポートに必要です。
//
InitializeComponent();
//
// TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
//
}
/**//// <summary>
/// 使用されているリソースに後処理を実行します。
/// </summary>
protected override void Dispose( bool disposing )
...{
if( disposing )
...{
if (components != null)
...{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows フォーム デザイナで生成されたコード#region Windows フォーム デザイナで生成されたコード
/**//// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
private void InitializeComponent()
...{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(100, 104);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(96, 56);
this.button1.TabIndex = 0;
this.button1.Text = "Run";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/**//// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
...{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
...{
System.Diagnostics.Process pro = System.Diagnostics.Process.Start(@"C:WINDOWSsystem32calc.exe");
if(pro!=null)
...{
pro.EnableRaisingEvents=true;
System.EventHandler hiEventHandler = new System.EventHandler(Do_Exited);
pro.Exited += hiEventHandler;
}
}
private static void Do_Exited(object sender, System.EventArgs e)
...{
MessageBox.Show("Done.");
}
}
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ProcessSample
... {
/**//// <summary>
/// Form1 の概要の説明です。
/// </summary>
public class Form1 : System.Windows.Forms.Form
...{
private System.Windows.Forms.Button button1;
/**//// <summary>
/// 必要なデザイナ変数です。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
...{
//
// Windows フォーム デザイナ サポートに必要です。
//
InitializeComponent();
//
// TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
//
}
/**//// <summary>
/// 使用されているリソースに後処理を実行します。
/// </summary>
protected override void Dispose( bool disposing )
...{
if( disposing )
...{
if (components != null)
...{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows フォーム デザイナで生成されたコード#region Windows フォーム デザイナで生成されたコード
/**//// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
private void InitializeComponent()
...{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(100, 104);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(96, 56);
this.button1.TabIndex = 0;
this.button1.Text = "Run";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/**//// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
...{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
...{
System.Diagnostics.Process pro = System.Diagnostics.Process.Start(@"C:WINDOWSsystem32calc.exe");
if(pro!=null)
...{
pro.EnableRaisingEvents=true;
System.EventHandler hiEventHandler = new System.EventHandler(Do_Exited);
pro.Exited += hiEventHandler;
}
}
private static void Do_Exited(object sender, System.EventArgs e)
...{
MessageBox.Show("Done.");
}
}
}