| 网站首页 | VB.Net实例分析 | .Net技术文摘 | 下载中心 | VB.Net书籍笔记 | .Net源码 | VBS脚本与组件调用 | Windows2008技术文摘 | 给我们留言 | 
最新公告:

  没有公告

您现在的位置: 乐博网 >> VB.Net实例分析 >> 系统管理编程 >> 实例分析正文
最新推荐 更多内容
创建刷新结束进程的实例
创建刷新结束进程的实例
作者:Ilu    来源:乐博网     更新时间:2009-11-3

创建刷新结束进程的实例

乐博网lob.cn提示:调试环境为 vs2005 +  windows2003 / windows2008 / xp / vista + .NET Framework 2.0

代码如下:

Public Class taskmgr
    '  Dim i As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.ListView1.ContextMenuStrip = ContextMenuStrip1
        ProcessList()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If MessageBox.Show("乐博网提示:确定结束进程", "结束进程", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then
            Dim proid As Integer = Int32.Parse(ListView1.SelectedItems(0).SubItems(1).Text)
            Dim pro As Process = Process.GetProcessById(proid)
            If Not pro.CloseMainWindow Then pro.Kill()
            pro.WaitForExit()
            pro.Close()
            ProcessList()
        End If
    End Sub
    Public Sub ProcessList()
        Try
            Dim pros() As Process
            Dim pro As Process
            pros = Process.GetProcesses
            ListView1.BeginUpdate()
            ListView1.Clear()
            ListView1.Columns.Add("进程名", 100, HorizontalAlignment.Center)
            ListView1.Columns.Add("进程ID", 100, HorizontalAlignment.Center)
            ListView1.Columns.Add("优先级", 100, HorizontalAlignment.Center)
            ListView1.Columns.Add("占用内存", 100, HorizontalAlignment.Center)

            For Each pro In pros
                Dim listviewitem As ListViewItem = New ListViewItem()
                listviewitem.Text = pro.ProcessName
                listviewitem.SubItems.Add(pro.Id.ToString)
                listviewitem.SubItems.Add(pro.BasePriority.ToString)
                listviewitem.SubItems.Add(pro.WorkingSet64.ToString)
                ListView1.Items.Add(listviewitem)
            Next
            ListView1.EndUpdate()
            Label1.Text = "进程数:" & pros.Length
        Catch e As Exception
            MessageBox.Show(e.Message)
        End Try
    End Sub
    Private Sub 刷新进程ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 刷新进程ToolStripMenuItem.Click
        Button3_Click(sender, e)
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ProcessList()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim properform As tPropertyForm = New tPropertyForm
        properform.Text = "乐博网:进程" & ListView1.SelectedItems(0).Text
        properform.proID = Int32.Parse(ListView1.SelectedItems(0).SubItems(1).Text)
        properform.ShowDialog()
    End Sub

    Private Sub 进程属性ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 进程属性ToolStripMenuItem.Click
        Button4_Click(sender, e)
    End Sub

    Private Sub 结束进程ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 结束进程ToolStripMenuItem.Click
        Button1_Click(sender, e)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim newp As tNewProcessForm = New tNewProcessForm
        newp.Text = "乐博网:新建进程"
        newp.ShowDialog()
    End Sub

    Private Sub 新建进程ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 新建进程ToolStripMenuItem.Click
        Button2_Click(sender, e)
    End Sub
    'Sub a()
    '    Dim pro As Process
    '    Dim pross() As Process
    '    pro = Process.GetCurrentProcess()
    '    pro = Process.GetProcessById(900)
    '    pross = Process.GetProcesses()
    '    pross = Process.GetProcessesByName("taskmgr")
    '    Process.Start("dsgg")
    '    pro.Close()
    'End Sub
End Class

  • 上一篇:

  • 下一篇: 没有了
  • 【字体: 】【打印此文】【关闭窗口
      相关文章:(只显示最新16条)
    等待进程执行完毕再继续的实例

    | 设为首页 | 加入收藏 | 联系站长 | | 友情链接 | 版权申明 |
    乐博网欢迎各种媒体转载我们的原创作品[转载请注明出处];我们鼓励更多VB.Net开发者一起加入研究与探讨;如发现文章访问错误、内容错误或版权疑问、内容有违相关法律(如涉及政治、色情、反动或散布虚假有害信息)等情况,请及时向我们举报,我们将及时纠正!
    联系邮箱:Shiny#vip.qq.com (#替换为@) QQ交流群: 40797788 [闽ICP备05014267号]