Show list of processes and how to Close it (Kill Process)
Use this board to post your code snippets - tips and tricks
6 posts
Page 1 of 1
For this Tutorial we need a Listbox and 2 Buttons
We will use the Listbox to display all the process that are running:
Button1 we be used to end the selected process from the list
Button2 will be used to get all the process and display them in the list box
Fist add the following to the very top of the code page:
We will use the Listbox to display all the process that are running:
Button1 we be used to end the selected process from the list
Button2 will be used to get all the process and display them in the list box
Fist add the following to the very top of the code page:
Code: Select all
Add the following code to Button2.Click event (Get List Button)
Imports System.Diagnostics
Code: Select all
Add the following code to Button1.Click event (End Process)
ListBox1.Items.Clear()
Dim a As System.Diagnostics.Process
For Each a In System.Diagnostics.Process.GetProcesses()
ListBox1.Items.Add(a.ProcessName)
Next
Code: Select all
Try
Dim a As System.Diagnostics.Process
For Each a In System.Diagnostics.Process.GetProcesses()
Dim list() As String = ListBox1.SelectedItem.ToString().Split("-")
Dim Process As String = list(0).Trim()
Dim iId As Integer = Convert.ToInt32(list(1).Trim())
If a.ProcessName = Process And a.Id = iId Then
a.Kill()
End If
Next
Button2.PerformClick()
Catch ex As Exception
MsgBox("Please Select a Process to kill from the list")
End Try
It is not clear why all that unneeded code is in the end process function.
You could use this:
You could use this:
Code: Select all
If ListBox1.SelectedIndex > -1 Then
Dim procs As Process() = Process.GetProcessesByName(ListBox1.SelectedItem.ToString())
For i As Integer = 0 To procs.Length - 1
procs(i).Kill()
Next
Button2.PerformClick()
End If
oh nice tut, once i get home i will make one. thanks !
First of all its a quick snip no tut. Second please dont bump unless you got a good question (mandai's post dated from 20 september 2011).
Sincerely,
Clanc789
Sincerely,
Clanc789
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
clanc789 wrote:First of all its a quick snip no tut. Second please dont bump unless you got a good question (mandai's post dated from 20 september 2011).wow shit sorry if that got you mad? i never look at the date thats why.
Sincerely,
Clanc789
lesan101 wrote:I doest get me mad, just that i dont want you that other members -rep you for this. A red block under your name doesnt help you when you ask help in the forum. Just FYI.clanc789 wrote:First of all its a quick snip no tut. Second please dont bump unless you got a good question (mandai's post dated from 20 september 2011).wow shit sorry if that got you mad? i never look at the date thats why.
Sincerely,
Clanc789
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023