hung pro vn

[VB] Start and Kill Processes

The following VB.NET program allows to start multiple calculator applications and later it kill the same instances of all calculator applications.
The Process component is a useful tool for starting, stopping, controlling, and monitoring applications. A process is a running application and a thread is the basic unit to which the operating system allocates processor time. Using the Process component, you can obtain a list of the processes that are running, or you can start a new process.
GetProcessesByName(String) - Creates an array of new Process components and associates them with all the process resources on the local computer that share the specified process name.

Dim _proceses As Process()
  _proceses = Process.GetProcessesByName("calc")
  

The above syntax retrieve all the process associated with "calc" application in the _proceses array. System.Diagnostics provides access to local and remote processes and enables you to start and stop local system processes.
FULL CODE :

Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		System.Diagnostics.Process.Start("calc")
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

		Dim _proceses As Process()
		_proceses = Process.GetProcessesByName("calc")
		For Each proces As Process In _proceses
			proces.Kill()
		Next

	End Sub

End Class

Hướng dẫn bình luận

Mọi người để lại bình luận góp ý, nhận xét về những bài viết mà mình chia sẽ văn minh lịch sự hay kích động, Không spam, không chèn link quảng cáo, bán hàng, Không sử dụng từ ngữ thô tục, xúc phạm, kích động, Link chỉ được phép khi thực sự liên quan đến nội dung bài viết, Không mạo danh người khác hoặc sử dụng email giả, Bình luận vi phạm sẽ bị xóa không cần thông báo trước.
Mọi người lưu ý răng, nếu muốn chia sẽ code ở bình luần thì cần mã hóa code trước khi bỏ vào khung nhé. :)
⑴ Chèn ℂ𝕤𝕤 theo mẫu : [pre css] CSS [/pre]
⑵ Chèn ℍ𝕥𝕞𝕝 theo mẫu : [pre html] HTML [/pre]
⑶ Chèn 𝕁𝕒𝕧𝕒𝕤𝕔𝕣𝕚𝕡𝕥 theo mẫu : [pre js] Javascript [/pre]

🖼️ Chèn 𝕀𝕞𝕒𝕘𝕖 theo mẫu : [img] Link hình ảnh [/img]
🎞️ Chèn Video 𝕐𝕠𝕦𝕥𝕦𝕓𝕖 theo mẫu : [youtube] Link Youtube [/youtube]

0 Nhận xét

Top