System Shutdown

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What componet do I need to added so that I can catch when the user pressed
the power button and prevent the system from shutting down. I am using the
system call OnQueryEndSessions().

Thanks,
Tim
 
Tim,

Well, I suppose you are referring to WM_QUERYENDSESSION. The OnQueryEndSessions is probably just a handler for the message since
your app is likely written in some high level language like VB.Net or C#, right? For handling this message you theoretically only
need the basics (Win32 support, kernel, etc.). No special components required but...

Depending on what your image is based on this may or may not work. IIRC, WM_QUERYENDSESSION only reliable works within Explorer
Shell/Winlogon environment (well, maybe only Explorer is the requirement).

In Minlogon environment you want to switch to handle WM_POWERBROADCAST / PBT_APMSUSPEND message instead. Some more info here:
http://groups-beta.google.com/group...gst&q=QueryEndSession&rnum=1#e37bdaea59bfc6f3
Although even with Minlogon you should be careful and make sure you are working with the latest updates. I don't remember which QFE
fixed it but there was a problem seeing with old Minlogon where intercepting the WM_POWERBROADCAST message wasn't working in some
configurations (search NG archive, we covered the topic quite in details long time ago).

I personally prefer SetConsoleCtrlHandler. It works more stable with Minlogon. Read more here:
http://groups-beta.google.com/group...&q=WM_QUERYENDSESSION&rnum=1#760fbfd6bb8f4d1c
 
Thanks.

KM said:
Tim,

Well, I suppose you are referring to WM_QUERYENDSESSION. The OnQueryEndSessions is probably just a handler for the message since
your app is likely written in some high level language like VB.Net or C#, right? For handling this message you theoretically only
need the basics (Win32 support, kernel, etc.). No special components required but...

Depending on what your image is based on this may or may not work. IIRC, WM_QUERYENDSESSION only reliable works within Explorer
Shell/Winlogon environment (well, maybe only Explorer is the requirement).

In Minlogon environment you want to switch to handle WM_POWERBROADCAST / PBT_APMSUSPEND message instead. Some more info here:
http://groups-beta.google.com/group...gst&q=QueryEndSession&rnum=1#e37bdaea59bfc6f3
Although even with Minlogon you should be careful and make sure you are working with the latest updates. I don't remember which QFE
fixed it but there was a problem seeing with old Minlogon where intercepting the WM_POWERBROADCAST message wasn't working in some
configurations (search NG archive, we covered the topic quite in details long time ago).

I personally prefer SetConsoleCtrlHandler. It works more stable with Minlogon. Read more here:
http://groups-beta.google.com/group...&q=WM_QUERYENDSESSION&rnum=1#760fbfd6bb8f4d1c
 
Well I modified the program and it doesn't catch anything like that. I just
updated to the newest release of the feature pack yesterday as well.
 
You can't catch anything like what?
You may want to post the related pieces of your code here so that we can review it and find possibly missing parts.

Also, for your own debugging, you can create a Winlogon/Explorer Shell image and test your app there. Then you'd know if your app is
written correctly and/or the issue is Minlogon related.
 
wm-powerbroadast or the pbt_apmsuspend. I am fairly sure that it is
something to do with the minlogon because the app was working with an image
that had the full logon client. So it looks like I will be stuck in the for
seeable future to using the winlogon....that sucks.

Tim
 
Tim,

It might be that newest Minlogon is again broken with regards to the WM_POWERBROADCAST. I'll check it out later here.

When you say you tested on old Winlogon image, do you mean you tested your *new* app with WM_POWERBROADCAST handler in place? Or
what it just the WM_QUERYENDSESSION that time? If latter, it won't work any way.

Btw, if you really want to stick with Minlogon, the SetConsoleCtrlHandler approach should work.
 
Back
Top