Board index » delphi » Restarting System and/or Windows

Restarting System and/or Windows

Quote
Wim Simons wrote:

> Is there anyone who can tell me if there is a way, in Delphi 1.0/2.0, to
> restart windows or to restart the system and windows ?

Wim:

There is a Win API function called ExitWindows() which takes two
parameters.  One of the following 3 calls should do the trick:

  {1) This simply exits Windows (back to DOS in 16-bit Windows)}
  ExitWindows(0,0);

  {2) This exits Windows and reboots the system}
  ExitWindows(MAKELONG(EW_REBOOTSYSTEM, 0), 0);

  {3) This closes all programs then restarts Windows}
  ExitWindows(MAKELONG(EW_RESTARTWINDOWS, 0), 0);

Enjoy,
-Jim Rofkar.

 

Re:Restarting System and/or Windows


Is there anyone who can tell me if there is a way, in Delphi 1.0/2.0, to
restart windows or to restart the system and windows ?

Re:Restarting System and/or Windows


Wim Simons <wsim...@club.innet.be> wrote in article
<328C3D31.2...@club.innet.be>...

Quote
> Is there anyone who can tell me if there is a way, in Delphi 1.0/2.0, to
> restart windows or to restart the system and windows ?

If you are using Windows95 then the function to restart windows is:
ExitWindowsEX(EWX_REBOOT, 0);

Re:Restarting System and/or Windows


On Fri, 15 Nov 1996 01:51:46 -0800, Wim Simons <wsim...@club.innet.be>
wrote:

Quote
>Is there anyone who can tell me if there is a way, in Delphi 1.0/2.0, to
>restart windows or to restart the system and windows ?

Look at the ExitWindows API Call.

Re:Restarting System and/or Windows


"James D. Rofkar" <jim_rofkar%lotusnot...@instinet.com> wrote:

Quote
>There is a Win API function called ExitWindows() which takes two
>parameters.  One of the following 3 calls should do the trick:

>  {1) This simply exits Windows (back to DOS in 16-bit Windows)}
>  ExitWindows(0,0);

>  {2) This exits Windows and reboots the system}
>  ExitWindows(MAKELONG(EW_REBOOTSYSTEM, 0), 0);

>  {3) This closes all programs then restarts Windows}
>  ExitWindows(MAKELONG(EW_RESTARTWINDOWS, 0), 0);

Hello there

I have tried that under Win NT 4.0 Workstation yesterday.

{2) will definitely not work. It will cause NT to _log_off_ the user
but it will not shut down.

I think all of these functions will only log off the user.

The Delphi32 Help says:
[quote on]
The ExitWindows function logs the current user off.
BOOL ExitWindows(
    DWORD  dwReserved,  // reserved
    UINT  uReserved     // reserved
   );  
Parameters
dwReserved Reserved; must be zero.
uReserved  Reserved; must be zero.
[Quote off]

[Quote on]
The ExitWindowsEx function either logs off, shuts down, or shuts down
and restarts the system.

EWX_REBOOT      Shuts down the system and then restarts the system.
The application must have the SE_SHUTDOWN_NAME privilege (for more
information, see the Remarks section).
[Quote off]

[Quote on]
The AdjustTokenPrivileges function adjusts privileges in the specified
access token. Enabling or disabling privileges in an access token
requires TOKEN_ADJUST_PRIVILEGES access.
[Quote off]

I could not manage to get the necessary privilieg and I did not find
any sample source code.

If anyone knows how to use "AdjustTokenPrivileges" (with a piece of
code?) I would be glad to get a mail or to read an answer here in the
usenet.

--
Greetings to everybody from Udo Burghardt

Re:Restarting System and/or Windows


On 19 Nov 1996 06:55:00 GMT, AmavGmbH...@t-online.de (Udo Burghardt) wrote:

Quote
>access token. Enabling or disabling privileges in an access token
>requires TOKEN_ADJUST_PRIVILEGES access.
>[Quote off]

>I could not manage to get the necessary privilieg and I did not find
>any sample source code.

>If anyone knows how to use "AdjustTokenPrivileges" (with a piece of
>code?) I would be glad to get a mail or to read an answer here in the
>usenet.

Udo,

that is done via the User Manager. This person needs SHUTDOWN privileges.
I've had this in the past, when NT 4 runs out of resources. I have to log
off, then shut the machine down.

You should check the user privileges first.

Happy coding

Stefan Paetow
CEO - ellipse data systems

-
=========================================================================
=  Any opinions here are my personal opinions, not those of my company  =
=          Home on the web: http://www.ellipse-data.com/                =
=     Maintainers of the South African Delphi Super Page Mirror at      =
=                    http://www.icon.co.za/~thelink/                    =
=========================================================================

Re:Restarting System and/or Windows


Quote
Wim Simons (wsim...@club.innet.be) wrote:

: Is there anyone who can tell me if there is a way, in Delphi 1.0/2.0, to
: restart windows or to restart the system and windows ?

Look up the API ExitWindows

. . Peter Y W Chiam . . . . . . . . <mailto:peter-ch...@mailhost.net> . .  
                  <a href=http://nusunix2.nus.sg/nussu/stud/eng40263>
    {*word*137} Software Engineer [Delphi1,Delphi2,VB3,VB4;Win31,Win95]
                                      .  
   If any one of you lack wisdom, let him ask of God, that giveth to all men
    liberally, and upbraideth not; and it shall be given him.  -- James 1:5

Other Threads