none
ShutdownBlockReason API with Shell Launcher RRS feed

  • Question

  • I have a Windows Forms application, which must run on Windows 8.1 Embedded Industry Pro, and I should handle, when the user tries to shut down the device with the hardware button.

    I am using the new Shutdown Reason API to block shutdown in my application as described here:

    https://msdn.microsoft.com/en-us/library/ms700677%28v=VS.85%29.aspx?f=255&MSPPError=-2147217396

    It works fine, when the Shell Launcher feature is turned off, but when I enable it, Windows won't ask to cancel or continue, just shuts down the application and the device.

    Can I somehow block or prevent Windows shutdown process, when Shell Launcher is active?

    Thanks is advance!

    Tamás

    Monday, July 27, 2015 11:58 AM

All replies

  • Out of curiosity, why do you want to present the cancel / continue? Does you application need to perform some actions before shutdown?

    Sean Liming - Book Author: Starter Guide SIM (WEI), Pro Guide to WE8S & WES 7, Pro Guide to POS for .NET - www.annabooks.com / www.seanliming.com

    Monday, July 27, 2015 3:44 PM
    Moderator
  • The device is a medical instrument, and should not be turned off while measuring or cleaning, etc. Of course this is user responsibility too, but I would like to prevent it. And it was possible on Windows XP Embedded.
    Tuesday, July 28, 2015 6:28 AM
  • If you are presenting a shutdown button to the user to press, you could make a call to safely shutdown the application and then call the shutdown API. Would that work?


    Sean Liming - Book Author: Starter Guide SIM (WEI), Pro Guide to WE8S & WES 7, Pro Guide to POS for .NET - www.annabooks.com / www.seanliming.com

    Tuesday, July 28, 2015 2:28 PM
    Moderator
  • The software has of course a shutdown button to press, this is the "official" way to turn off device, but my original question was to handle the hardware button. Could we return to the topic please?

    Can Windows 8.1 Embedded handle this while Shell Launcher is active or not?

    Wednesday, July 29, 2015 9:26 AM
  • You could change the power schemes so that power button does nothing through "Change what the power buttons do" in the Power Options or with powercfg.

    Ben

    Wednesday, July 29, 2015 12:02 PM
  • If Shell launcher is active, I assume that you are launching a custom application. Explorer.exe is not running. My guess is that there is something hooked with Explorer.exe. As a test, you could run explorer.exe silently and try the power button to see what happens.

    You could also disable the power button from shutdown in the Power options to force the use of the Official way.


    Sean Liming - Book Author: Starter Guide SIM (WEI), Pro Guide to WE8S & WES 7, Pro Guide to POS for .NET - www.annabooks.com / www.seanliming.com

    Wednesday, July 29, 2015 4:28 PM
    Moderator
  • Thank you for the tip, I tried running explorer.exe, but unfortunately it did not work. I can't disable the power button, because the user must be able to turn off the device when the OS or the software freezes, or there is an emergency.

    Now I try to compare the running processes when Shell Launcher is turned on and off.

    Thursday, July 30, 2015 9:09 AM
  • If system freezes, holding the power button should still work and shutdown system so I don't see the problem.

    Ben

    Thursday, July 30, 2015 12:14 PM
  • Another option is to change the power button to suspend. Would suspend work in your case.

    Also, I thought about programmatically taking control of the power button, but a search lead me to this: http://stackoverflow.com/questions/16179460/how-to-control-power-button-press-shutdown  which says it is impossible.


    Sean Liming - Book Author: Starter Guide SIM (WEI), Pro Guide to WE8S & WES 7, Pro Guide to POS for .NET - www.annabooks.com / www.seanliming.com

    Thursday, July 30, 2015 4:45 PM
    Moderator