如何用c#遍历wince进程并终止指定进程
2个回答
展开全部
用WMI遍历...
Imports System
Imports System.Management
Imports System.Windows.Forms
Namespace VBdotNetExample
Public Class MyWMIQuery
Public Overloads Shared Function Main() As Integer
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_Process")
For Each queryObj As ManagementObject in searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_Process instance")
Console.WriteLine("-----------------------------------")
Console.WriteLine("ProcessId: {0}", queryObj("ProcessId"))
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Function
End Class
End Namespace
Imports System
Imports System.Management
Imports System.Windows.Forms
Namespace VBdotNetExample
Public Class MyWMIQuery
Public Overloads Shared Function Main() As Integer
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_Process")
For Each queryObj As ManagementObject in searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_Process instance")
Console.WriteLine("-----------------------------------")
Console.WriteLine("ProcessId: {0}", queryObj("ProcessId"))
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Function
End Class
End Namespace
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询