我有一個C#應用程序來查找用戶的「開始工作」和「完成工作」事件。我們的目標是獲得一個包含日期時間值的列表,當一臺PC「上」並再次「下」時。我在哪裏可以找到有關窗口處於待機模式的信息
這是工作登錄/註銷和休眠,但不是待機(save energy
)。使用eventvwr
進行搜索我無法找到連接到「進入待機」和「從待機狀態喚醒」的正確事件。
有了這個,我從Windows事件日誌閱讀:
public SortedDictionary<string, UserProfileEvent> ReadUserProfileEvents() {
string queryString = string.Format("*[System[TimeCreated[@SystemTime>='{0}' and @SystemTime<='{1}']]]", this.StartDate.ToString("s"), this.EndDate.ToString("s"));
var q = new EventLogQuery("Microsoft-Windows-User Profile Service/Operational", PathType.LogName, queryString);
var r = new EventLogReader(q);
var liste = new SortedDictionary<string, UserProfileEvent>();
EventRecord e = r.ReadEvent();
UserProfileEvent upe = null;
while (e != null) {
upe = new UserProfileEvent(e);
try {
liste.Add(upe.SortKey, upe);
}
catch (Exception exp) {
throw new Exception("Some error text", exp);
}
e = r.ReadEvent();
}
return liste;
}
任何想法在哪裏可以找到正確的事件?
編輯:我剛剛發現「Microsoft-Windows-Power-Troubleshooter」和「Microsoft-Windows-Kernel-Power」。這些協議似乎指向正確的方向...
但是我不想對事件做出反應,我想在過去的幾個星期裏得到一個「開始活躍」和「結束活躍」的列表。 – Shnugo