取得相關處理序的唯一識別項

因為工作上需要
程式須要自動判斷
是否有重覆執行的處理序識別
並將重覆的PID結束
判斷與結束的程式已被我 delete
留給有興趣的朋友動動腦
相關文件請至MSDN http://msdn.microsoft.com/zh-tw/library/system.diagnostics.process.aspx

 'Initial Width and Height 
        Me.Size = New Size(240, 360) 
 
        ' Create a new ListView control. 
        Dim listView1 As New ListView() 
        listView1.Bounds = New Rectangle(New Point(12, 12), New Size(200, 300)) 
 
        ' Set the view to show details. 
        listView1.View = View.Details 
 
        ' Allow the user to edit item text. 
        listView1.LabelEdit = False 
 
        ' Allow the user to rearrange columns. 
        listView1.AllowColumnReorder = True 
 
        ' Display check boxes. 
        listView1.CheckBoxes = False 
 
        ' Select the item and subitems when selection is made. 
        listView1.FullRowSelect = True 
 
        ' Display grid lines. 
        listView1.GridLines = True 
 
        ' Sort the items in the list in ascending order. 
        listView1.Sorting = SortOrder.Ascending 
 
        ' Create columns for the items and subitems. 
        listView1.Columns.Add("ProcessName", 130, HorizontalAlignment.Left) 
        listView1.Columns.Add("PID", 50, HorizontalAlignment.Right) 
 
        ' For Each loop to collect Processes 
        For Each p As Process In Process.GetProcesses() 
            Dim lvi As New ListViewItem() 
            lvi.Text = p.ProcessName : lvi.SubItems.Add(p.Id.ToString()) 
            listView1.Items.Add(lvi) 
        Next 
 
        ' Add the ListView to the control collection. 
        Me.Controls.Add(listView1)

沒有留言:

張貼留言