Hey
So I got this idea to write a very small application for a school project that raises a balloon from the system tray everytime a new process is getting launched or an existing process quits.
With my current code, I am getting the list of processes using a timer.
This list needs to be compared with the previous list and detect differences (if this is possible, or should I use a different concept)? I have no clue how to do this.
I currently have:
-A ListView (ListView1), with the View property to "Details"
-A Timer (at a 5000ms interval), with the following code:
Code:
Dim processList() As Process
processList = Process.GetProcesses()
For Each proc As Process In processList
Dim Item As New ListViewItem
Item.Text = proc.Id.ToString
Item.SubItems.Add(proc.ProcessName.ToString)
Item.SubItems.Add(proc.Responding.ToString)
ListView1.Items.Add(Item)
Next
Anyone can help me out with the comparison part?
tl;dr: Need some help with a piece of code to notify the user if a new process started or an existing process quit.
Last edited by DumbAndDumber; Jun 15th, 2011 at 11:37 AM.
If my post helped you out, please rate me! Thread resolved? Mark it as Resolved!
It obviously doesn't work because you did not follow the instructions in that article. Did you run mgmtclassgen.exe to generate the Process class and then rename it to Win32_Process? That is the comment near the end of that code which reads:
Code:
' Auto-Generated running: mgmtclassgen Win32_Process /n root\cimv2 /o WMI.Win32
' Renaming the class from Process to Win32_Process
Public Class Win32_Process
...
End Class
All you did was just copy the partial code shown in the article and converted it into VB.Net without even checking to see if the code is complete.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it. - Abraham Lincoln -
It obviously doesn't work because you did not follow the instructions in that article. Did you run mgmtclassgen.exe to generate the Process class and then rename it to Win32_Process? That is the comment near the end of that code which reads:
Code:
' Auto-Generated running: mgmtclassgen Win32_Process /n root\cimv2 /o WMI.Win32
' Renaming the class from Process to Win32_Process
Public Class Win32_Process
...
End Class
All you did was just copy the partial code shown in the article and converted it into VB.Net without even checking to see if the code is complete.
I ran the mgmtclassgen tool from the command-line and the Run-box but it gives an error (file not found).
I'm pretty new to (Visual Basic) .NET, so I don't understand everything.
What should I do?
If my post helped you out, please rate me! Thread resolved? Mark it as Resolved!
I ran the mgmtclassgen tool from the command-line and the Run-box but it gives an error (file not found).
I'm pretty new to (Visual Basic) .NET, so I don't understand everything.
What should I do?
You should be able to run the command from VS's command prompt (not Windows' cmd.exe one).
Anyway, here is the whole thing that I've converted to VB.Net for you. Download the attached WMIWin32.vb file below. I haven't actually tested it but if the original C# code works then there is no reason the VB.Net version of it doesn't.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it. - Abraham Lincoln -