Board index » delphi » Programming WinNT auto shut-down, WM_CLOSE, WM_QUIT

Programming WinNT auto shut-down, WM_CLOSE, WM_QUIT

Programming WinNT auto shut-down, WM_CLOSE, WM_QUIT

Win 95/98 shuts the computer off automatically, NT Service Pack 3
does not offer this, can one program that with the Win32 API and
Delphi.  I find that:

    sendmessage(FindWindow(nil,nil),WM_CLOSE,0,0);

brings up the Shut-down Windows options display, but also causes
Windows to become unstable, and restarting becomes the only option to
regain stability.

WM_QUIT and WM_ENDSESSION seem to do nothing.

The Win32 documentations refers to a log-off flag which applies in
Win95 only, not Win NT.

Is there a hack by which I can get Win NT to
shut the machine down programmatically?

Please email me. I thankfully reply.
--------------------------------------------
M...@lottery.powernet.co.uk
--------------------------------------------
Sorry, I do not have a return address in my message header to avoid
the email gathering robots. Please cut and paste my email from here
thanks. M...@lottery.powernet.co.uk

Please email me. I thankfully reply.
--------------------------------------------
M...@lottery.powernet.co.uk
--------------------------------------------
Sorry, I do not have a return address in my message header to avoid
the email gathering robots. Please cut and paste my email from here
thanks. M...@lottery.powernet.co.uk

 

Re:Programming WinNT auto shut-down, WM_CLOSE, WM_QUIT


On Fri, 28 May 1999 21:41:58 GMT,

Quote
PleaseSeeAddr...@TheBottom.OfMyMessage.co.uk (Hello) wrote:
>Programming WinNT auto shut-down, WM_CLOSE, WM_QUIT

>Win 95/98 shuts the computer off automatically, NT Service Pack 3
>does not offer this, can one program that with the Win32 API and
>Delphi.  I find that:

>    sendmessage(FindWindow(nil,nil),WM_CLOSE,0,0);

>brings up the Shut-down Windows options display, but also causes
>Windows to become unstable, and restarting becomes the only option to
>regain stability.

>WM_QUIT and WM_ENDSESSION seem to do nothing.

>The Win32 documentations refers to a log-off flag which applies in
>Win95 only, not Win NT.

>Is there a hack by which I can get Win NT to
>shut the machine down programmatically?

Use this :
//=====================================
var
  Success : boolean;

// Set system privilege for NT
if SetPrivilege('SeShutdownPrivilege', True) then
   Success := ExitWindowsEx(Flags, 0);

//=====================================

Flags are
   EWX_LOGOFF, EWX_REBOOT, EWX_SHUTDOWN all of which can be OR-ed with

   EWX_POWEROFF, and EWX_FORCE.

Grillix

- Show quoted text -

Quote
>--------------------------------------------
>M...@lottery.powernet.co.uk
>--------------------------------------------

Re:Programming WinNT auto shut-down, WM_CLOSE, WM_QUIT


Hi, I tried this but Delphi doesn't recognize : SetPrivilege.... am I
missing a Uses clause or something ??

Thanks,   Bye
Vic

Quote

> Use this :
> //=====================================
> var
>   Success : boolean;

> // Set system privilege for NT
> if SetPrivilege('SeShutdownPrivilege', True) then
>    Success := ExitWindowsEx(Flags, 0);

> //=====================================

> Flags are
>    EWX_LOGOFF, EWX_REBOOT, EWX_SHUTDOWN all of which can be OR-ed with

>    EWX_POWEROFF, and EWX_FORCE.

> Grillix

> >--------------------------------------------
> >M...@lottery.powernet.co.uk
> >--------------------------------------------

Other Threads