Shutdown the system

Following a message from Dionissis in the forum in which he asked the needed to restart a computer from his application I wrote this component. It encapsulates the functionality of Windows to acomplish this task in a simple way and it does the necessary checks to each plaftorm.

Using this component, we have a chance to shutdown, restart, etc. These are the methods:

    METHOD ShutdownDlg( nSeconds ), shows the “Shutdown dialog” and waits for user action. The parameter nSeconds indicates how many seconds to shown the dialog, but is only valid in Vista.

    METHOD Shutdown( lForce ), frees all buffers disk, ends active processes and puts the system in a position to be shut down safely.

    METHOD Reboot( lForce ), reboots the system.

    METHOD Logoff( lForce ), ends all the processes and closes the session.

    METHOD Poweroff( lForce ), close the system and then off.

    METHOD ShutdownPower( lForce ), puts the system in Shutdown() state and then off.

    METHOD Suspend( lForce ), suspends the system.

    METHOD Hibernate( lForce ), hibernates the system.

    METHOD SetAsLastProcess(), registers the application to be the last user process to end.

This component has a DATA called nLastError which is updated each time a method can’t do his job. To check what is failing or if we want to show to the user what happened we can use the Xailer’s function MsgSysError( nError ).

The ZIP includes the library ready for Xailer 1.9 or newer.

Regards,
José Lalín

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.