频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

用VB.NET获得系统进程列表

来源: 作者: 出处:巧巧读书 2006-09-05 进入讨论组

  Retrieving information on system resources and process information was not possible wihtout API calls in VB6. Calling API functions has its own difficulties. Identifying correct datatypes, Identifying the API functions, having ErrorHandles to avoid app Crashes are some of those..

VB.NET relieves us from all such problems by providing class libraries to access system resources and environment information. Here is a simple example In VB.NET, that depicts the method to get the list of of processes that are currently running in your system.

1) Place a button in the form
2) Place a TextBox in the Form and name it as txtProcesses
3) Set the Multi-line property of the TextBox(txtProcesses) to True
4) Import the System namespace
5) Write the following code in the CommandButton click Event


        Dim sProcesses() As System.Diagnostics.Process
        Dim sProcess As System.Diagnostics.Process
  Dim s As String
        On Error Goto ErrorHandler

        sProcesses = System.Diagnostics.Process.GetProcesses()
        s = ""
        s = vbCrLf & "ProCSS Info " & vbCrLf

        For Each sProcess In sProcesses
            s = s & sProcess.Id & Space(5) & sProcess.ProcessName() & vbCrLf
        Next

  txtProcesses.Text = s
ErrorHandler:
MsgBox "Unexpected Error occurred"

System.Diagnostics.Process is NameSpace provides the method GetProcesses() to get the list of process running in your system. This function returns  Object array  of type Process. The ID and ProcessName properties of the Process object can be used to retrive the ProcessID(PID) and the Name process.

The overloaded function GetProcesses with << System Name >> parameter can be invoked to get list of processes running in a remote system.

Happy programming with VB.NET.
 Web: http://www.qqread.com/vbdotnet/d240352.html 更多文章 更多内容请看系统优化大全系统安全设置系统安装手册专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
最新论坛文章
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章