2010/12/30

VB.net Process ExecutablePath(Process MainModule Filename Failed In Windows 7)

VB.net
  1. Dim query As New System.Management.ManagementObjectSearcher()
  2. query.Query = New System.Management.ObjectQuery("SELECT * FROM Win32_Process WHERE Name LIKE 'chrome%'")
  3. Dim queryCollection As System.Management.ManagementObjectCollection = query.Get()
  4. For Each mo As System.Management.ManagementObject In queryCollection
  5.     Dim ID As Integer = mo("ProcessId")
  6.     Dim Name As String = mo("Name")
  7.     Dim Path As String = mo("ExecutablePath")
  8.     System.Diagnostics.Debug.WriteLine(String.Format("{0},{1},{2}", ID, Name, Path))
  9. Next

沒有留言: