开发者

Not able to detect windows logon

I have a windows service code which detects logoff and logon. the service detects logoff but its not detecting logon.

public ServiceLogoff()
        {  this.CanHandleSessionChangeEvent = true;               开发者_StackOverflow中文版        
        }
protected override void OnSessionChange(SessionChangeDescription changeDescription)
        {
if (changeDescription.Reason == SessionChangeReason.SessionLogoff)
            {
tw.WriteLine("logoff detected" + DateTime.Now);
}
else if(changeDescription.Reason == SessionChangeReason.SessionLogon)
            {
tw.WriteLine("logon detected" + DateTime.Now);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜