以编程方式防止Windows关闭 [英] Programmatically prevent Windows to shutdown

查看:106
本文介绍了以编程方式防止Windows关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只要我的 Delphi 应用正在运行,我想阻止 Windows XP 关机,我尝试了以下操作:

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;

但这似乎不起作用。其他建议有人吗?

TIA

Steven

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

推荐答案

以下是答案您的问题:

检测并防止Windows关闭
http://delphi.about.com/cs/adptips2000/a/bltip0500_4.htm

这篇关于以编程方式防止Windows关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆