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
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- 系统优化大全 (17810篇文章)
- 系统安全设置 (23152篇文章)
- 系统安装手册 (20517篇文章)
- 系统备份专题 (17271篇文章)
- Windows系统进程专题 (92篇文章)
- 系统维护手册 (16661篇文章)
- .NET移动与嵌入式技术 (5882篇文章)
- .NET开发手册 (5587篇文章)
- 系统进程使用问题 (80篇文章)
- 系统各进程详解 (147篇文章)
- VB.NET 入门教程 (22167次浏览)
- VB.NET读写文本文件方法 (579次浏览)
- vb.net入门——MDI 窗体的基础使用 (342次浏览)
- 浅析Visual Basic.NET中的资源使用 (322次浏览)
- vb.net入门——PictureBox控件的使用 (268次浏览)
- vb.net入门——ToolBar 控件的使用 (267次浏览)
- vb.net入门——DateTimePicker 控件的使用 (260次浏览)
- vb.net入门——Splitter 控件的使用 (254次浏览)
- vb.net入门——Windows窗体中的菜单操作 (243次浏览)
- vb.net入门——ComboBox 控件的使用 (218次浏览)



