Andrea said:
I need to detect when another application is launched. I'd need to
know also when a new folder is opened in explorer. I'm developing an
application to speed up access to frequently used applications.
I don't see how this could help you to "speed-up access to frequently used
applications", but for your first requirement you can use System.Management
and WMI (see code snip) , the second only possible (reliably) through a
Filesystem filter driver, something that is out of the domain of .NET.
class WMIEvent {
public static void Main() {
WMIEvent we = new WMIEvent();
ManagementEventWatcher w= null;
WqlEventQuery q;
try {
q = new WqlEventQuery();
q.EventClassName = "Win32_ProcessStartTrace";
w = new ProcessStartEventArrived(q);
w.EventArrived += new
EventArrivedEventHandler(we.ProcessStartEventArrived);
w.Start();
Console.ReadLine(); // block main thread for test purposes
}
finally {
w.Stop();
}
}
public void ProcessStartEventArrived(object sender, EventArrivedEventArgs
e) {
foreach(PropertyData pd in e.NewEvent.Properties) {
Console.WriteLine("\n======================================");
Console.WriteLine("{0},{1},{2}",pd.Name, pd.Type, pd.Value);
}
}
Willy.