2

How can I get all the processes and their respective programs and dlls running in Windows?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Wakko
  • 95
  • 1
  • 3
  • 10

1 Answers1

0

There's no easy way to do that, as Java doesn't have an interface to Windows API. The easiest way I can think of is this:

    Process proc = Runtime.getRuntime().exec("tasklist /M");
    InputStream is = proc.getInputStream());
    // and now read and parse that long output, listing all processes and DLLs...

This does require some work on the parsing, but it saves you from getting out of the Java world.

Eran
  • 21,632
  • 6
  • 56
  • 89
  • Could you give me some link for understanding the process class ? – Wakko Jul 04 '12 at 02:22
  • @WesleyKhan, it's a standard Java class - see the [Java Doc](http://docs.oracle.com/javase/6/docs/api/java/lang/Process.html). There's some sample code you can use [here](http://stackoverflow.com/questions/3643939/java-process-with-input-output-stream). – Eran Jul 04 '12 at 07:35