开发者

Not able to detect windows logon

开发者 https://www.devze.com 2023-03-29 11:21 出处:网络
I have a windows service code which detects logoff and logon. the service detects logoff but its not detecting 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

精彩评论

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