我有一个记录一些用户数据的应用程序。如果用户注销工作站,则需要保存此信息。
该程序是一个 windows 窗体 c# 应用程序。
目前我正试图通过下面的这个函数来做到这一点,它可以工作到 95%,但不能达到 100%。
Application.Run(new Shutdown(_object));
private void Shutdown_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;``
_object.LogLogout(); //Save the logout to a file
}
我也尝试了该功能,但这根本不起作用。我不明白为什么。有什么提示吗?我完全被困在这里。
Microsoft.Win32.SystemEvents.SessionEnded += new Microsoft.Win32.SessionEndedEventHandler(SystemEvents_SessionEnded);
Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEnding(SystemEvents_SessionEnding);