473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to catch system event of new process that are loaded

Hi all .

I want to know when new process has added\loaded, i looked for system
event but i could not find any.
Is there any way to do it ?

I'm writing in c#.NET.

(Process Added meand that new process added to the task manager)

Apr 5 '07 #1
5 7137
<ei********@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
Hi all .

I want to know when new process has added\loaded, i looked for system
event but i could not find any.
Is there any way to do it ?

I'm writing in c#.NET.

(Process Added meand that new process added to the task manager)

Using System.Management anamespace classes and the WMI class Win32_ProcessStartTrace, you
can trace process creation events.
Note that you need to run as administrator for this to work :-(

Here is a small sample to get you started....
....
WqlEventQuery q = new WqlEventQuery( "Win32_ProcessStartTrace");
using(ManagementEventWatcher w = new ManagementEventWatcher(q)){
w.EventArrived += new EventArrivedEventHandler(ProcessStartEventArrived) ;
w.Start();
Console.ReadLine(); // block main thread for test purposes
w.Stop();
}
}
static void ProcessStartEventArrived(object sender, EventArrivedEventArgs e) {
//Get the Event object and display it's properties
foreach(PropertyData pd in e.NewEvent.Properties)
Console.WriteLine("{0} : {1}",pd.Name, pd.Value);
}
....

Willy.

Apr 6 '07 #3
"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
Like this: http://www.codeproject.com/cs/system...usingwmi.asp??

I won't use this sample, it's not reliable as it's based on polling, it's too easy to miss
events on a loaded system.
See my other reply for a more reliable option.

Willy.

Apr 6 '07 #4
Cheers Willy - good advice. I Knew that WMI was the answer; the
specific article was google-fodder. Cheers for suggesting a better
option.

Marc

Apr 6 '07 #5
"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
Cheers Willy - good advice. I Knew that WMI was the answer; the
specific article was google-fodder. Cheers for suggesting a better
option.

Marc
Well, the article also uses WMI, but it uses the wrong WMI class.

Willy.

Apr 6 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
2
by: thechaosengine | last post by:
Hi everyone, Is there anyway to create some sort of catch-all in windows forms applications that could ensure that no unexpected exceptions bring down an application? For example, perhaps...
2
by: David N | last post by:
Hi All, The OnLoad() event is invoked automatically when a form is being loaded. Do we have another event that is invoked automatically after a form has completed loading? Thanks.
8
by: CarpetMnuncher! | last post by:
================================================================= How do I use Try Catch error handling when a timer is involved? If I preform the preciduer below and I get an error I revive...
4
by: Strah | last post by:
Is there a way to catch the event of terminating the application from the the processes tab in task manager? I have created windows app, and if a user termintates the app in the task manager,...
0
by: Pete | last post by:
Hi All, I'm new to this so please correct me if I'm wrong. I have written a small program which holds details for task information. the program holds an email address, i created a button which...
1
by: Pete | last post by:
Hi All, I'm new to this so please correct me if I'm wrong. I have written a small program which holds details for task information. the program holds an email address, i created a button which...
9
by: =?Utf-8?B?RCBKYXJ2aWU=?= | last post by:
A VB.NET 2003 application accesses a custom VB 6 DLL. It has run successfully several months, and has been modified without problem a few times during that period. Recently another set of changes...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.