2010年3月9日 星期二

程式管理

image

Public Class Form1
    Dim proc As System.Diagnostics.Process
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Interval = 5000
        Timer1.Enabled = True
        Me.Hide()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If CheckBox1.Checked = True Then
            For Each proc In System.Diagnostics.Process.GetProcesses
                If proc.ProcessName Like "*iexplore*" Then proc.Kill()
            Next
        End If
        If CheckBox2.Checked = True Then
            For Each proc In System.Diagnostics.Process.GetProcesses
                If proc.ProcessName Like "*mspaint*" Then proc.Kill()
            Next
        End If
        If CheckBox3.Checked = True Then
            For Each proc In System.Diagnostics.Process.GetProcesses
                If proc.ProcessName Like "*calc*" Then proc.Kill()
            Next
        End If

        If TextBox1.Text <> "" Then
            Dim proc1 = "*" & TextBox1.Text & "*"
            For Each proc In System.Diagnostics.Process.GetProcesses
                If proc.ProcessName Like proc1 Then proc.Kill()
            Next
        End If

        If TextBox2.Text <> "" Then
            Dim proc1 = "*" & TextBox2.Text & "*"
            For Each proc In System.Diagnostics.Process.GetProcesses
                If proc.ProcessName Like proc1 Then proc.Kill()
            Next
        End If

        If TextBox3.Text <> "" Then
            Dim proc1 = "*" & TextBox3.Text & "*"
            For Each proc In System.Diagnostics.Process.GetProcesses
                If proc.ProcessName Like proc1 Then proc.Kill()
            Next
        End If
    End Sub
End Class

沒有留言: