"The code is exactly
how I would like to write code and the algorithms used are very
efficient and well-documented."
Van T. Dinh, Microsoft MVP
|
|
Class: CShutdown
Shutting down Windows with options to restart and logoff This class allows you to shutdown Windows in one of four ways:
- Shutdown
- Restart
- Logoff
- Shutdown with Power Off
|
Procedure Name
|
Type
|
Description
|
|
(Declarations)
|
Declarations
|
Declarations and private variables for the CShutdown class
|
|
ForceReboot
|
Property
|
Sets whether or not the class forces Windows to reboot regardless of running process status.
If this property is set to True, the system does not send the WM_QUERYENDSESSION or WM_ENDSESSION messages to processes. This can result in data loss, and should only be used in an emergency.
|
|
ShutdownMode
|
Property
|
Sets the shutdown mode
This class supports four types of shutdown modes:
Mode Enum Type Description
-------------------------------------
Shutdown esmShutdown Shuts down Windows.
Logoff esmLogOff Closes all current processes and logs the current user off. After Shtudown is complete, all disk buffers have been flushed to disk, and all processes have been stopped.
PowerOff esmPowerOff Same as Shutdown, but also turns the computer power off if the your hardware supports this.
Reboot esmReboot Same as Shutdown, but also reboots the computer
|
|
AdjustToken
|
Private
|
NT requires that you have SE_SHUTDOWN_NAME privilege. VB apps don't have this by default, so this procedure grants it.
|
|
IsNT
|
Private
|
Determines if the OS is Windows NT
|
|
MakeFlags
|
Private
|
Builds the flags long integer from class property values.
|
|
Shutdown
|
Method
|
Shuts down Windows (according to the mode specified by the ShutdownMode property and the Force property) by calling the ExitWindowsEX API function
The ExitWindowsEX function returns as soon as it has been called--all subsequent activity related to the shutdown is then handled asynchronously by Windows. When a shutdown is initiated, all applications are informed that they need to shutdown. If an application does not respond after a specific period of time, Windows displays a dialog allowing you to:
- Forcibly shut down the application
- Retry the shutdown
- Cancel the shutdown
If you set the Force property to True, Windows always forces applications to close and does not display the dialog.
|
Overview of Total Visual SourceBook
The source code in Total Visual
SourceBook includes modules and classes for Microsoft Access, Visual
Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily
add this professionally written, tested, and documented royalty-free code
into your applications to simplify your application development efforts.
Additional Resources
|
|