开发者

handle user logoff or machine shutdown requests on WindowsME

开发者 https://www.devze.com 2022-12-27 02:43 出处:网络
I have to write a C# application that runs on WindowsME. Yes, I mean that Microsoft operating system that has been forgotten a long long time ago. My program needs no user interaction and as WindowsME

I have to write a C# application that runs on WindowsME. Yes, I mean that Microsoft operating system that has been forgotten a long long time ago. My program needs no user interaction and as WindowsME doesn't support services, it will be a console application. Furthermore i开发者_开发知识库t will be used on more modern operating systems, where the user can choose whether to start it as console application or install it as a windows service. Now suppose the software is running on WinME and the user decides to logoff or shutdown the machine without a prior quit of my software. WinME complains about my program still running and asks if it should kill the process. Apart from the bad user experiance, this means that the application is not shut down properly.

So I look for a way to be informed if the user logs off or wants to shutdown the machine to be able to perform a proper shutdown of my software first.


I think WM_ENDSESSION is supported by Windows ME so I think you should try to catch that event. That's the one sent out to all top level windows when the Windows session is ending (via logout or shutdown).


Have you tried handling SystemEvents.SessionEnding/SystemEvents.SessionEnded? To use this you will need to create a hidden form, I believe the MSDN example demonstrates this.

http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.aspx

0

精彩评论

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