当用户使用Windows 7提供的Switch用户选项从一个帐户切换到另一个帐户时,我想在我的Windows窗体应用程序中执行一组任务。那么我们是否有一些系统事件来处理此切换用户案例?
I think SystemEvents.SessionSwitch
is what you need. You can listen to a new user logging in and count that as a user switch, since your app is still active (else you would have a logoff first).
Occurs when the currently logged-in user has changed.
I guess the logic for a user switch is:
Both events can be handled by this event.
I know this is old, but I didn't see a helpful answer. You do need to handle the SystemEvents.SessionSwitch event. When a Windows user switches to another user, the SessionSwitchEventArgs from the event will have a Reason property that is a SessionSwitchReason enum with the value of "ConsoleDisconnect". When the user switches back, it should have a value of "ConsoleConnect".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.