using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

//Przestrzeń nazw, którą do projektu dodał Server Explorer
using ServerExplorerExamples.ROOT.CIMV2;

namespace ServerExplorerExamples
{
	/// <summary>
	/// Summary description for WMIExample.
	/// </summary>
	public class WMIExample : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ListView processView;
		private System.Windows.Forms.ColumnHeader ProcessName;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public WMIExample()
		{
			InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#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 void InitializeComponent()
		{
			this.processView = new System.Windows.Forms.ListView();
			this.ProcessName = new System.Windows.Forms.ColumnHeader();
			this.SuspendLayout();
			// 
			// processView
			// 
			this.processView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																						  this.ProcessName});
			this.processView.Location = new System.Drawing.Point(8, 8);
			this.processView.Name = "processView";
			this.processView.Size = new System.Drawing.Size(256, 160);
			this.processView.TabIndex = 0;
			this.processView.View = System.Windows.Forms.View.Details;
			// 
			// ProcessName
			// 
			this.ProcessName.Text = "Nazwa procesu";
			this.ProcessName.Width = 235;
			// 
			// WMIExample
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 266);
			this.Controls.Add(this.processView);
			this.Name = "WMIExample";
			this.Text = "WMIExample";
			this.Load += new System.EventHandler(this.WMIExample_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void WMIExample_Load(object sender, System.EventArgs e)
		{
	
			//Przejście w pętli przez kolekcję procesów i dodawanie
			//wierszy do listy processView

			foreach(Process p in Process.GetInstances())
			{
				processView.Items.Add(p.Name);
			}

		}
	}
}
