Hi all,

I have 2 applications: one, let's call it the babysitter and the second
one my-app. The babysitter starts when the system starts and it is its
job to start my-app, and in case this one crashes or so to restart it.
Basically it babysitts my-app. Both are running in the background,
without any user interaction.

Because they have to always run, I wanted to make sure they don't end up
dead in case a user is doing for instance:
- chose shut-down system
- half of the applications are going down
- then there is let's say an opened notepad which was not saved
- user is asked what to do
- he canceles the shut-down
in this moment, all the app that were already killed will remain killed,
even though the system is still running.
In order to avoid this problem, I used the SetProcessShutdownParameters
(the same dwLevel=0x100 for both my applications) to let these 2
applications to get last the shut-down messages. So, when they get the
WM_ENDSESSION/WM_QUERYENDSESSION, the chances are that the system
shut-down can't be canceled anymore.

I read somewhere (and my tests proved) that the applications with the
same level of shutting down will get the shut-down messages in the order
they were started.

This works just fine on Win2k and XP:
- babysitter starts first
- my-app is started afterwards by the babysitter
- when system goes down, as babysitter was the first one started the
babysitter dies before my-app
- afterwards dies my-app

This DOESN'T work on Vista:
- babysitter starts first
- my-app is started afterwards by the babysitter
- when system goes down, for some reason my-app dies first, so the
babysitter before getting the shut-down message, tries to restart my-app
which ends up with Vista showing an ugly popup ("my-app can't be
initialized bla-bla"). I can see in the logs that my-app gets the
WM_ENDSESSION/WM_QUERYENDSESSION 4 secs before the babysitter gets them.

Why is the shut-down message received first by my-app and later by the
babysitter and not vice-versa as it was on WinXP? What else has changed
in the shut-down procedure in Vista?

Thank you in advance,