问题描述
您好,
我的应用程序一旦启动,将永远在系统托盘中运行。它还记录了应用程序中发生的所有事件。现在我有一个要求是"如果用户关闭或重新启动系统,我的应用程序必须在日志文件(文本文件)中记录
日志。"如何在C#.net 2.0中完成。
My application will be running in system tray forever once it is been launched. And also it is logging all events occurred in application in text file. Now I got one requirement is that "If user shut down or restart the system, my application has to log regarding this in log file(text file)." How can I do it in C# .net 2.0.
我们将不胜感激。
最诚挚的问候,
Best Regards,
Hari
点击"建议作为答案"如果这篇文章解决了你的问题或"投票有帮助"如果一篇文章对你有用,快乐编程! Hari
click "Proposed As Answer by" if this post solves your problem or "Vote As Helpful" if a post has been useful to you Happy Programming! Hari
推荐答案
感谢您在此发帖,
对于您的问题,您可以尝试使用PowerModeChanged事件。
For your question, you could try to use PowerModeChanged Event.
当用户挂起或恢复操作系统或系统电源状态时,会引发PowerModeChanged事件通知发生。当检测到弱电或充电电源时,或者当AC或电池电源发生转换
时,可能会发生系统电源状态通知。
A PowerModeChanged event is raised when the user suspends or resumes the operating system, or when a system power status notification occurs. A system power status notification can occur when a weak or charging power source is detected, or when a transition from AC or battery power source occurs.
有关详细信息,您可以请参阅MSDN文章。
For more details, you could refer to the MSDN article.
https://msdn.microsoft.com/en-us/library/microsoft.win32.powermodechangedeventargs(v = vs.110).aspx
Best问候,
Wendy
这篇关于如何在C#中重启或关闭Windows日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!