Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Me.TopMost = True
- Me.Focus()
- For Each Proc As Process In Process.GetProcesses()
- ListBox1.Items.Add(Proc.ProcessName)
- ListBox2.Items.Add(Proc.Id)
- Proc.Start()
- Next
- Private Sub Proc_Tick(sender As Object, e As EventArgs) Handles Proc.Tick
- 'variáveis
- Dim actualProcess as String
- Dim ListBox1Items as String
- Dim actualProcessExists as Boolean = False
- Dim ProcID as Integer
- '----------------------------------------------
- actualProcess = "explorer"
- ListBox1Items = ListBox1.Items.Count - 1
- 'Checando se o processo existe
- For ia As Integer = ListBox1Items To 0 Step -1
- ListBox1.SelectedIndex = ia
- If ListBox1.SelectedItem = actualProcess Then
- actualProcessExists = True
- Else
- Proc.Stop()
- Proc2.Start()
- End If
- Next
- '----------------------------------------------------------
- 'Adicionando PID à outra ListBox
- If actualProcessExists = True Then
- For i As Integer = ListBox1Items To 0 Step -1
- ListBox1.SelectedIndex = ia
- If ListBox1.SelectedItem = actualProcess Then
- ListBox2.SelectedIndex = ListBox1.SelectedIndex
- ProcID = ListBox2.SelectedItem
- ListBox2.Items.Add(ProcID)
- Else
- Proc.Stop()
- Proc2.Start()
- End if
- End Sub
Add Comment
Please, Sign In to add comment