|
-
Jan 16th, 2006, 10:23 AM
#1
Thread Starter
Hyperactive Member
Creating an event handler to find out when a process starts
Hi everyone. Me again. I have a little problem I hope somebody help me. I know how to create an event handler to a process such as notepad so that when the process is exited, some kind of event is triggered eg.
private Process NPad;
...
Process[] p = Process.GetProcessesByName("notepad");
if(p.Length > 0)
{
NPad = p[0];
lbl1.Text = "Notepad is started.";
NPad.EnableRaisingEvents = true; // Set Enable events to true.
NPad.Exited += new EventHandler(NPad_Exited); // Set the event handler.
}
....
// Event handler code
private void NPad_Exited(object sender, EventArgs e)
{
// Some Action to be taken e.g.
lbl1.Text = "Notepad Stopped";
}
.
.
.
.
.
.
The problem I am having is that I also want to set some kind of event to trigger when a process like notepad is started and not just exited. The above code shows how to set an event when notepad is exited. Does anyone know how to set an event to trigger when notepad is started?
Thanking for any kind of help in advance.
Jennifer.
-
Jan 16th, 2006, 10:49 AM
#2
Re: Creating an event handler to find out when a process starts
Maybe you can find something here. The third post on the page looks like it would do the trick
-
Jan 16th, 2006, 02:04 PM
#3
Thread Starter
Hyperactive Member
Re: Creating an event handler to find out when a process starts
Thanks penagate. I will read it over and see if i get the solution, if I do I will put it up here. And wishing you a wonderful 2006 penegate!!! - jennifer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|