Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Call killprocess function and send the name of the program you'd like to kill
killprocess("calc") 'ชื่อ process ที่จะ kill
End Sub
Public Function killprocess(ByVal processname As String)
'Get list of all running processes
Dim proc() As Process = Process.GetProcesses
'Loop through all processes
For i As Integer = 0 To proc.GetUpperBound(0)
If proc(i).ProcessName = processname Then
'kill process if name is calc
proc(i).Kill()
MessageBox.Show("ปิด process calculator เรียบร้อยแล้ว!", "www.thaicreate.com", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Next
End Function
End Class