Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports ROOT.CIMV2

Namespace ServerExplorerExamples
	''' <summary>
	''' Summary description for WMIExample.
	''' </summary>
	Public Class WMIExample : Inherits System.Windows.Forms.Form
		Private processView As System.Windows.Forms.ListView
		Private ProcessName As System.Windows.Forms.ColumnHeader
		''' <summary>
		''' Required designer variable.
		''' </summary>
		Private components As System.ComponentModel.Container = Nothing

		Public Sub New()
			InitializeComponent()
		End Sub

		''' <summary>
		''' Clean up any resources being used.
		''' </summary>
		Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
			If disposing Then
				If Not components Is Nothing Then
					components.Dispose()
				End If
			End If
			MyBase.Dispose(disposing)
		End Sub

		#Region "Windows Form Designer generated code"
		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()
			Me.processView = New System.Windows.Forms.ListView()
			Me.ProcessName = New System.Windows.Forms.ColumnHeader()
			Me.SuspendLayout()
			' 
			' processView
			' 
			Me.processView.Columns.AddRange(New System.Windows.Forms.ColumnHeader() { Me.ProcessName})
			Me.processView.Location = New System.Drawing.Point(8, 8)
			Me.processView.Name = "processView"
			Me.processView.Size = New System.Drawing.Size(256, 160)
			Me.processView.TabIndex = 0
			Me.processView.View = System.Windows.Forms.View.Details
			' 
			' ProcessName
			' 
			Me.ProcessName.Text = "Nazwa procesu"
			Me.ProcessName.Width = 235
			' 
			' WMIExample
			' 
			Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
			Me.ClientSize = New System.Drawing.Size(292, 266)
			Me.Controls.Add(Me.processView)
			Me.Name = "WMIExample"
			Me.Text = "WMIExample"
'			Me.Load += New System.EventHandler(Me.WMIExample_Load);
			Me.ResumeLayout(False)

		End Sub
		#End Region

		Private Sub WMIExample_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

			'Przejście w pętli przez kolekcję procesów i dodawanie
			'wierszy do listy processView

			For Each p As Process In Process.GetInstances()
				processView.Items.Add(p.Name)
			Next p

		End Sub
	End Class
End Namespace
