1. What window flags are set in the examples you've seen?
2. Override winEvent and look for the WM_QUERYENDSESSION. More details on http://msdn2.microsoft.com/en-us/library/aa376890.aspx. You should set the result param of winEvent to a non-zero value, so the shut-down/restart won't halt. When you catch this event you should also close your app.
Bookmarks