[RESOLVED] get new process and execute action to it
What i would like to do is:
1.the user will load a file with some strings in a listview with 3 columns
2.a timer will run and see if a new process that is not in the listview is opened(i want to get the mainmodule.filename of the process and compare it to ListView1.Items.Item(index).SubItems(2).Text (which is the third column)
3.if it is not in the list then form2.show else if it is in the list check to see what column 2 say about it .subitems(1).text
at nr 3 i thought of something like this in case it's not detected in the list
Code:
Dim Frm as new Form2
Frm.text = process.processname
Frm.tag = process.mainmodule.filename
Frm.Show
and cause of this i don't want to be spammed by forms with the same process, so make something that will ignore that item,but not stop the timer in case new processes start
So i need help at point 2 and 3
Re: get new process and execute action to it
Quote:
so make something that will ignore that item
If you want the timer to continue then surely the thing to do is to add the new process to the ListView or at least a second list that will also be checked on each tick?
You are however going to have problems with getting the module filename of many system processes as access is denied even at the highest permissions level.
Re: get new process and execute action to it
so how do i check a process (string) with the listview1 string and if it is there do nothing else start form2?
Code:
Dim proc As New Process
For Each proc In Process.GetProcesses
For i = 0 To ListView1.Items.Count - 1
If ListView1.Items.Item(i).SubItems(1).Text = proc.MainModule.FileName Then
If ListView1.Items.Item(i).SubItems(2).Text = "BL" Then
'do nothing maybe a later time make it do something
End If
Else
ListView1.Items.Add(proc.ProcessName)
ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add(proc.MainModule.FileName)
ListView1.Items.Item(ListView1.Items.Count - 1).SubItems.Add("AL")
Dim frm As New form2
frm.show()
End If
Next
Next
it doesnt do what i want , just spamms me and the listview with different items
i know that in the above code it takes each item for each process and thats why i get spammed but how would i just check the process for all the items in listview 1 without doing a for i 0 to items.count-1
Re: get new process and execute action to it
If you're checking all values, no matter what they are nor in what context, you have to use a loop (be it explicit or implicit as in LINQ). There simply is no alternative.
Re: get new process and execute action to it
i still don't get it what am i supposed to do?
can u help me with the code because it stresses me, i get more problems than solutions