I'm trying to make an embedded windows 7 application shut the machine down gracefully.
I've tried this:
ExitWindowsEx(EWX_POWEROFF | EWX_FORCE,
SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
SHTDN_REASON_MINOR_UPGRADE |
SHTDN_REASON_FLAG_PLANNED);
which appears to instantly kill everything (my app doesn't exit cleanly, it just dies).
I've tried swapping EWX_FORCE
for EWX_FORCEIFHUNG
but that presents the user with a dialog which, in contrast to the docs doesn't seem to offer any timeout.
Is there a way of doing this elegently or do I simply need to record the need to shutdown and then call the forcible shutdown as the last thing my app does?