- 10 名前:前スレ958 mailto:sage [2008/06/08(日) 22:39:52 ]
- 参考にして書いた.NETバージョンです
public static DateTime イベントログの前回停止時間() { EventLog[] logs = EventLog.GetEventLogs("."); // ローカルコンピュータ DateTime result = DateTime.MinValue; bool ok = false; foreach (EventLog log in logs) { if (log.Log != "System") continue; foreach (EventLogEntry e in log.Entries) { if (e.EventID != 6006) continue; if (e.TimeGenerated > result) { result = e.TimeGenerated; ok = true; } } } if (!ok) { throw new ApplicationException("イベントログの前回停止時間の取得失敗"); } return result; }
|

|