With:
using System.Diagnostics;
foreach (EventLog log in EventLog.GetEventLogs())
{
if (log.Log == "Security")
{
foreach (EventLogEntry e in log.Entries)
{
switch (e.InstanceId)
{
case 4672:
dataGridViewNamesAndTimes.Rows.Add("Special Logon", e.TimeGenerated);
break;
case 4625:
dataGridViewNamesAndTimes.Rows.Add("An account failed to log on", e.TimeGenerated);
break;
}
}
break;
}
}
I now only need to check the InstanceId in
Windows Security Log Events[
^] and check which events I want to show in the datagrid, with checkboxes to toggle show/hide of each of the event Ids...
Would someone please help me find the InstanceIds of these actions since the explanations in the link above aren't always accurate and are fuzzy?
When the user:
1- Logged in.
2- Logged out.
3- Restarted PC.
4- Shut down PC.
5- Turned on PC.
6- Hibernated PC.
7- Suspended (sleep) PC.