|
-
Apr 5th, 2013, 03:55 PM
#1
Thread Starter
New Member
[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
Last edited by Cristea221; Apr 5th, 2013 at 04:00 PM.
-
Apr 5th, 2013, 04:16 PM
#2
Re: get new process and execute action to it
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.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 6th, 2013, 08:29 AM
#3
Thread Starter
New Member
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
Last edited by Cristea221; Apr 6th, 2013 at 08:36 AM.
-
Apr 6th, 2013, 03:07 PM
#4
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.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 7th, 2013, 02:51 PM
#5
Thread Starter
New Member
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|