Hi All,
To test wether that program "second.exe" are stop running using this code below.It seem not working.
Thank.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management;
using System.Diagnostics;
using System.Threading;
using System.IO;
namespace mag_3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ManagementEventWatcher stopWatch = new ManagementEventWatcher(new WqlEventQuery("SELECT * FROM Win32_ProcessStartTrace"));
try
{
stopWatch.EventArrived += new EventArrivedEventHandler(this.Bulk_);
stopWatch.Start();
}
catch (Exception)
{
MessageBox.Show("Can't start the Process-Monitor! Are you running as admin?");
return;
}
}
private void Bulk_(object sender, EventArrivedEventArgs e)
{
listBox1.Items.Add("Process stop: {0}" + e.NewEvent.Properties["Second.exe"].Value);
}
}
}