Detecting application launch

  • Thread starter Thread starter Andrea
  • Start date Start date
A

Andrea

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.
 
Hi,

I don't know of a direct method of detecting a new app start. I can think
of two approaches?
1- Using Process.GetProcesses()
2- Using EnumWindows() Win32 function

neither of them is a fast solution though.

Did you google it?

cheers,
 
Hi,

I don't know of a direct method of detecting a new app start. I can think
of two approaches?
1- Using Process.GetProcesses()
2- Using EnumWindows() Win32 function

neither of them is a fast solution though.

Did you google it?

cheers,

I tried google but could not find anything. My original idea was to
have a timer and check the list of opened windows but in this way I
could miss some.
Thanks.
 
You can easily create a processlist and scan through it on a timer
looking for particular programs and while I can't say it's exact there
is a class called FileSystemWatcher(?) that allows you to setup events
to watch and monitor paths and/or file types.
 
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.
 
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.

Thanks Willy. What I would like to do is create a list of the last
applications launched and also a list of the last accessed files to
present that to the user so that he can see what files has been
recently used.

For the second thing I would create a timer that looks for opened
applications.

One more thing: is there a way to detect which files an application
has opened. I would like to retrieve a list of all the last used files
on the system.

Thanks again.
 
One more thing: is there a way to detect which files an application
has opened. I would like to retrieve a list of all the last used files
on the system.

I don't think you can get useful information for this: an application
can open numerous configuration (etc) files, besides the file "it is
working on". Say for Word: you don't want to log every access to
Normal.dot in addition to the "real" doc files.

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top