|
Technical answers from the trenches |
|
Restarting Windows from ObjectPAL
| ||||
by Liz A. Woodhouse and Lance Leonard |
Posted: 1 August 2000 |
|||
(based on an unknown newsgroup posting)  |
Applies to: Paradox 7.32 and later |
|||
  |
Audience: Intermediate |
|||
Question: How can I restart Windows from ObjectPAL?Answer: The following code sample demonstrates this:
Uses User32
ExitWindowsEx( uFlags CLONG, dwReserved CLONG ) CLONG
endUses
method pushButton( var eventInfo Event )
var
uFlags longInt
dwReserved longInt
endvar
uFlags = 2 ;// Reboot computer before restarting Windows
dwReserved = 0 ;// Always set to zero;
ExitWindowsEx( uFlags, dwReserved )
endMethod
How it works:ExitWindowsEx shuts down or reboots the user's computer. This starts the process immediately, so should only be used after any required processing is performed. For example, if you use tCursors in the method that calls this function, be sure to close them before calling ExitWindowsEx; otherwise, unposted changes will be lost. ExitWindowsEx returns non-zero values if successful or a zero (0) if there's an error. While it may seem odd this think of errors ocurring by restarting Windows, it can happen. For example, suppose you have a "dirty" form open in Paradox when you trigger this. Normally, Paradox prompts you to save your form. If you choose Cancel from that prompt, Paradox blocks the shutdown process. Windows considers this an "error" (because it didn't complete as expected). If you are working with something that returns a value, you should always check those values to ensure that something unexpected hasn't prevented your process from completing properly. The uFlags parameter controls the type of restart that Windows performs and supports the following values:
The parentheses in the above list show the names of the corresponding Windows constants. Developers using languages with direct access to the Windows API should use these instead of the hard-coded values, in case Microsoft chooses to change the effects of specific values in a future version of Windows. The dwReserved flag is reserved by Microsoft for future expansion; it should always be set to zero (0). |
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|