<pre lang="c#">public void WatchForProcessStart() { string queryString = "SELECT TargetInstance" + " FROM __InstanceCreationEvent " + "WITHIN .025 " + " WHERE TargetInstance ISA 'Win32_Process' " + " AND TargetInstance.Name like '%'"; // The dot in the scope means use the current machine string scope = @"\\.\root\CIMV2"; // Create a watcher and listen for events startProcWatcher = new ManagementEventWatcher(scope, queryString); startProcWatcher.EventArrived += ProcessStarted; startProcWatcher.Start(); } startProcWatcher.EventArrived += ProcessStarted; private void ProcessStarted(object sender, EventArrivedEventArgs e) { string eventType = e.NewEvent.ClassPath.ClassName; if(eventType=="__InstanceCreationEvent") { Console.WriteLine("Event arrived"); } } The above code is working when i open first excel file but when i open another excel file then that time this code is not working. Thanks in Advance.
i have tried with __ModifiedCreationEvent but it will occur continues. please suggest what to do for it.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)