Guest User

Untitled

a guest
Nov 13th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2. Me.TopMost = True
  3. Me.Focus()
  4.  
  5. For Each Proc As Process In Process.GetProcesses()
  6. ListBox1.Items.Add(Proc.ProcessName)
  7. ListBox2.Items.Add(Proc.Id)
  8. Proc.Start()
  9. Next
  10.  
  11. Private Sub Proc_Tick(sender As Object, e As EventArgs) Handles Proc.Tick
  12. 'variáveis
  13. Dim actualProcess as String
  14. Dim ListBox1Items as String
  15. Dim actualProcessExists as Boolean = False
  16. Dim ProcID as Integer
  17. '----------------------------------------------
  18. actualProcess = "explorer"
  19. ListBox1Items = ListBox1.Items.Count - 1
  20.  
  21. 'Checando se o processo existe
  22. For ia As Integer = ListBox1Items To 0 Step -1
  23. ListBox1.SelectedIndex = ia
  24. If ListBox1.SelectedItem = actualProcess Then
  25. actualProcessExists = True
  26. Else
  27. Proc.Stop()
  28. Proc2.Start()
  29. End If
  30. Next
  31. '----------------------------------------------------------
  32.  
  33. 'Adicionando PID à outra ListBox
  34.  
  35. If actualProcessExists = True Then
  36. For i As Integer = ListBox1Items To 0 Step -1
  37. ListBox1.SelectedIndex = ia
  38. If ListBox1.SelectedItem = actualProcess Then
  39. ListBox2.SelectedIndex = ListBox1.SelectedIndex
  40. ProcID = ListBox2.SelectedItem
  41. ListBox2.Items.Add(ProcID)
  42. Else
  43. Proc.Stop()
  44. Proc2.Start()
  45. End if
  46. End Sub
Add Comment
Please, Sign In to add comment