Q:

Programmatically prevent Windows to shutdown

I want to prevent Windows XP from powering down as long as my Delphi app is running, and I tried the following:  
procedure TForm1.FormCreate(Sender: TObject);
begin
  SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, nil, 0);
  SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, nil, 0);
  SystemParametersInfo(SPI_SETLOWPOWERACTIVE, 0, nil, 0);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, nil, 0);
  SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 1, nil, 0);
  SystemParametersInfo(SPI_SETLOWPOWERACTIVE, 1, nil, 0);
end;

but that doesn't seem to work. Other suggestions anyone?
TIA
Steven

A:

Here is the answer to your question:
Detecting and preventing Windows shut down
http://delphi.about.com/cs/adptips2000/a/bltip0500_4.htm

