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

  没有公告

您现在的位置: 乐博网 >> VB.Net实例分析 >> 实例学习笔记 >> 实例分析正文
最新推荐 更多内容
[图文]任务管理器编程(VB2010实例)
任务管理器编程(VB2010实例)
作者:Akyao    来源:乐博网收集     更新时间:2011-4-5

任务管理器编程(VB2010实例)

ProcessClass:Process 类用于执行各种任务,如命令行处理和列出有关当前正在运行的进程的信息

ProcessViewer:通过调用 GetProcesses 方法将当前计算机上的进程将显示在 ListView 控件中

乐博网Akyao认为windows2003自带的任务管理器还是有挺多不足,比如没有办法显示进程的cmdline ,win7和win2008的就好了不少,不过也没关系,如果你会了本文的编程方法,你就可以自己开发更强大的任务管理器了。

 

如果你想下载本文的源代码RAR压缩集合包  请访问
VB2010源代码集合包(芋头糕)    http://www.lob.cn/code/utility/2795.shtml
特别感谢网友 芋头糕 将此资源提供乐博网分享,欢迎加入 40797788 的.Net超级qq群交流。

VB2010源码如下:

' Copyright (c) Microsoft Corporation. All rights reserved.
Public Class TaskManager

    ' List of processes currently running
    Dim processList As New System.Collections.Generic.List(Of ProcessInfo)


    Private Sub btnModules_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModules.Click
        ' Get the item that is currently selected in the combo box.  Then all of the modules
        ' for that process are displayed to the user via the richTextBox on frmModules.
        Dim processID As Integer = (CType(cboCurrentProcesses.SelectedItem, ProcessInfo)).ID
        Dim modulesForm As New ModulesDisplay
        modulesForm.ProcessID = processID
        modulesForm.Show()
    End Sub

    Private Sub TaskManager_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            ' Loop through all the running process, and add them to the ComboBox
            ' so that the user can select a process and see the information
            ' for that process.
            For Each oneProcess As Process In Process.GetProcesses()
                ' Devenv is the Visual Studio Development Environment.  You will see one entry
                ' for each instance of the development environment that you have open. IEXPLORE is
                ' the Internet Explorer.
                If oneProcess.ProcessName = "乐博网" Or oneProcess.ProcessName = "lob" Then
                    processList.Add(New ProcessInfo(oneProcess.Id, oneProcess.ProcessName))
                End If
            Next
            cboCurrentProcesses.DataSource = processList
            With cboCurrentProcesses
                .DataSource = processList
                .SelectedIndex = 0
            End With

            If btnModules.Enabled = False Then
                btnModules.Enabled = True
            End If
        Catch exc As Exception
            MsgBox("乐博网提示您:Unable to load process names: " & vbCrLf & "Choose another process.", MsgBoxStyle.OKOnly, Me.Text)
            btnModules.Enabled = False
        End Try
    End Sub

    Private Sub cboCurrentProcesses_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboCurrentProcesses.SelectedIndexChanged
        Dim processID As Integer

        Try

            ' Retrieve the information for the process based on the item that the
            ' user has selected in the combo box.
            'Dim ProcessListIndex As Integer = cboCurrentProcesses.SelectedIndex
            processID = (CType(cboCurrentProcesses.SelectedItem, ProcessInfo)).ID
            Dim ProcessInfo As Process = _
                Process.GetProcessById(processID)

            'Information is displayed about the currently selected process.
            txtPriority.Text = ProcessInfo.BasePriority.ToString()
            txtNumberOfThreads.Text = ProcessInfo.Threads.Count.ToString()
            txtMaxWorkingSet.Text = ProcessInfo.MaxWorkingSet.ToString()
            txtMinWorkingSet.Text = ProcessInfo.MinWorkingSet.ToString()
            txtStartTime.Text = ProcessInfo.StartTime.ToLongTimeString()
            txtTotalProcessorTime.Text = ProcessInfo.TotalProcessorTime.ToString()
        Catch exc As Exception
            MsgBox("乐博网提示您:Unable to retrieve information for ProcessID : " & processID & ".", MsgBoxStyle.OKOnly)
        End Try

    End Sub

    Private Class ProcessInfo
        Public ID As Integer
        Public Name As String
        Public Sub New(ByVal newId As Integer, ByVal newName As String)
            ID = newId
            Name = newName
        End Sub
        Public Overrides Function ToString() As String
            Return Name
        End Function
    End Class

End Class

  • 上一篇:

  • 下一篇:
  • 【字体: 】【打印此文】【关闭窗口
      相关文章:(只显示最新16条)
    管理计算机电源状态的类(VB2010实例)
    Tablet PC 上可用的文本识别选项(VB2010实例)
    Tablet PC 2005 中对笔势的系统识别(VB2010实例)
    自定义数据控件(VB2010实例)
    Tablet PC 2005 的区分上下文功能(VB2010实例)
    响应数字化仪触笔背面的橡皮擦(VB2010实例)
    WMI编程实例(VB2010实例)
    系统服务管理实例(VB2010实例)
    进程管理(VB2010实例)
    显示进程组成模块(VB2010实例)
    性能计数器编程(VB2010实例)
    消息队列MSMQListener(VB2010实例)
    消息队列MSMQClient(VB2010实例)
    写入事件日志(VB2010实例)
    读取事件日志(VB2010实例)
    创建和删除事件日志(VB2010实例)

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