Analysis and Evaluation of the Windows Event Log - Bill Buchanan
Analysis and Evaluation of the Windows Event Log - Bill Buchanan
Analysis and Evaluation of the Windows Event Log - Bill Buchanan
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
C:\Documents <strong>and</strong> Settings\Barrie\My ...\<strong>Windows</strong>Application6\Form1.cs<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.<strong>Windows</strong>.Forms;<br />
using System.Diagnostics;<br />
1<br />
namespace <strong>Windows</strong>Application6<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
private void button1_Click(object sender, <strong>Event</strong>Args e)<br />
{<br />
if (timer1.Enabled == false)<br />
{<br />
richTextBox1.Text = "";<br />
timer1.Enabled = true;<br />
}<br />
else<br />
{<br />
timer1.Enabled = false;<br />
}<br />
}<br />
private void timer1_Tick(object sender, <strong>Event</strong>Args e)<br />
{<br />
PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "%<br />
Processor Time", "_Total", true);<br />
cpuCounter.NextValue();<br />
System.Threading.Thread.Sleep(100);// 0.1 second wait<br />
string myText = cpuCounter.NextValue() + "%";<br />
string myTime = Convert.ToString(DateTime.Now);<br />
richTextBox1.Text += myTime + " : " + myText + "\r\n";<br />
richTextBox1.Select(richTextBox1.Text.Length + 1, 2);<br />
richTextBox1.ScrollToCaret();<br />
}<br />
}<br />
}<br />
private void button2_Click(object sender, <strong>Event</strong>Args e)<br />
{<br />
timer1.Enabled = false;<br />
string savedFile = "";<br />
saveFileDialog1.InitialDirectory = "C:";<br />
saveFileDialog1.Title = "Save Output to File!";<br />
saveFileDialog1.FileName = "Output.txt";<br />
saveFileDialog1.Filter = "Text Files|*.txt|All Files|*.*";<br />
if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)<br />
{<br />
savedFile = saveFileDialog1.FileName;<br />
richTextBox1.SaveFile(savedFile, RichTextBoxStreamType.PlainText);<br />
}<br />
}