Visual Basic - Kiểm tra toàn bộ process trong taskmanager

  • Thread starter Thread starter DumbDude
  • Ngày gửi Ngày gửi

DumbDude

Youtube Master Race
Cho mình hỏi có cách nào để kiểm tra toàn bộ các Process đang chạy được không? Mình muốn kiểm tra xem hiện có bao nhiêu process đang chạy và lấy tên từng process đó, ai biết cách làm xin chỉ giáo
 
The System.Diagnostics.Process class can be used to start and stop system processes. The GetProcesses function returns all running processes on the machine. The GetProcesses has two definition. One is for local machine and other for remote machine.

If you want processes on the local machine, you use GetProcesses(), else you use GetProcesses(string machinename).

Public Shared GetProcesses()() As Process
Public Shared GetProcesses(String)() As Process

Sample:

Dim procList() As Process = Process.GetProcesses()
Dim i As Integer
For i = 0 To 20- 1 Step i + 1
Dim strProcName As String = procList(i).ProcessName
Dim iProcID As Integer = procList(i).Id
Next

NOTE: Don't forget to add reference to System.Diagnostics and write this line in your using list:

Imports System.Diagnostics

You can even start, stop or kill processes by using Process class's methods.
 
Back
Top