25.12.2014 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CO42019 – Project 4<br />

Modifying <strong>the</strong> registry<br />

The following code will display <strong>the</strong> current start-up settings for <strong>the</strong> event log <strong>and</strong> allow <strong>the</strong> user to modify it.<br />

using System;<br />

using System.Collections.Generic;<br />

using System.Text;<br />

using Micros<strong>of</strong>t.Win32;<br />

namespace ConsoleApplication2<br />

{<br />

class Program<br />

{<br />

static void Main(string[] args)<br />

{<br />

RegistryKey key =<br />

Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Services\\<strong>Event</strong><strong>Log</strong>", true);<br />

if (key.GetValue("Start") != null) //Check <strong>the</strong> value actually exists<br />

{<br />

// The value exists<br />

Console.WriteLine("Its value started at: " + (int)key.GetValue("Start"));<br />

Console.WriteLine("Please select a new value (2, 3 or 4): ");<br />

String newNumString = Console.ReadLine();<br />

int newNum = Convert.ToInt32(newNumString);<br />

if (newNum >1 && newNum

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!