Windows Processes enumaration with timer?

I have this program which enumerates processes and what I'm trying to do is have a timer to refresh the list, the timer works but I have two questions:

1. The listview flickers badly... I tried using double buffer but it didn't help unless I was using it wrong? any help with this please? do you want to see the code?

2. The important thing is: is there a way to only "refresh" or "update" the list IF the process list changes?

-thanks
This should eliminate the flicker:

1
2
3
SendMessage(hListView, WM_SETREDRAW, FALSE, 0);
// Add items
SendMessage(hListView, WM_SETREDRAW, TRUE, 0);
Last edited on
Thanks man, actually DOUBLE BUFFER did the trick, I was sending it at the wrong "time" silly mistake, I appreciate it, this + DOUBLE BUFFER completely gets rid of it.

I would still like to know if there actually is a way to only update if a new process has sprung?
would storing the items in the snap shot and then with a timer check if the snapshot items increase work? it seems like a hassle though :/
Last edited on
Come on there has got to be a way, I know I've seen programs update the list only when a new process pops up... task manager is an example.
See http://www.codeproject.com/KB/threads/procmon.aspx for source code of a sample console application and the required driver.

You probably need to download and install the Windows Driver Development Kit in order to compile the driver project.
would storing the items in the snap shot and then with a timer check if the snapshot items increase work? it seems like a hassle though :/

This is pretty much how I did it in an old project. I kept a list of processes in memory and had a thread that constantly updated the list and another thread that updated the listview control, adding new processes or removing old processes.
Last edited on
This is what I'm doing gpotw, I store the value of how many processes are opened and if there is an increase I add it, works great BUT when it comes to checking if there is a decrease it kind of fails.

I'm going to have to check each process name and then delete accordingly.
Ok so I just have a variable that stores the number of processes and then I check to see if the new variable is bigger ( meaning new processes ) then I add the process, but I can't seem to do the oppisite, (when the new variable is smaller) so how would I go about that?
Well you could use a nested loop... If NewCount < OldCount then for each process in the listview, if it doesn't exist in the new list, remove it. This is how I did it and the main reason I used separate threads, so it wouldnt' tie up the GUI thread with the constant looping. You probably shouldn't compare process names as multiple processes could be running with the same name so maybe compare PID instead.

I didn't look much at webJose's link but if it can signal your application when processes are created and destroyed its probably the best solution...
Last edited on
What I'm doing is creating a list then adding the items to the list view and taking a snapshot every second, I run the loop for as many new processes showed up then add the process to the listview.

I was using process name to check the list but then I obviously saw the problem and now I'm using PID, it seems to work pretty well, I do the same thing to remove the items, for now it is working pretty well, I hope I'm not back for more questions, thanks for your help.

EDIT: there is a much easier way.... when you compare lists, if there was ANY change just "refresh" the list view :/ works best.
Last edited on
Topic archived. No new replies allowed.