using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.Diagnostics;

namespace myProcess
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Process.Start("notepad.exe");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Process.Start("notepad.exe", @"process.txt");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //Es muss ein Benutzer VCSharpUser mit dem Passwort "p@sSW0rD" existieren

            System.Security.SecureString pwd = new System.Security.SecureString();
            pwd.AppendChar('p');
            pwd.AppendChar('@');
            pwd.AppendChar('s');
            pwd.AppendChar('S');
            pwd.AppendChar('W');
            pwd.AppendChar('0');
            pwd.AppendChar('r');
            pwd.AppendChar('D');

            //Process.Start("notepad.exe", "VCSharpUser", pwd, "WORKGROUP"); //oder
            Process.Start("notepad.exe", @"process.txt", "VCSharpUser", pwd, "WORKGROUP");
        }

        private void button4_Click(object sender, EventArgs e)
        {
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = @"notepad.exe";
            psi.Arguments = @"process.txt";
            psi.WorkingDirectory = @".";

            Process.Start(psi);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = @"process.txt";
            psi.Verb = "print";

            Process.Start(psi);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            Process.Start("notepad.exe");
            Process.Start("notepad.exe");
            Process.Start("notepad.exe");
            Process.Start("notepad.exe");
            Process.Start("notepad.exe");
            Process[] p = Process.GetProcessesByName("notepad");

            p[0].EnableRaisingEvents = true;

            p[0].Exited += new EventHandler(Process_Exited);

            p[0].CloseMainWindow();
        }

        void Process_Exited(object sender, EventArgs e)
        {
            MessageBox.Show("Prozess wird über Prozess-Komponente geschlossen", "Process");
            
        }

        private void button7_Click(object sender, EventArgs e)
        {
            Process p;
            p = Process.Start("notepad.exe");
            p.WaitForInputIdle(3000);

        }
    }
}