我在程序中处理了WM_QUERYENDSESSION WM_ENDSESSION
系统在重启时间程序成功
但系统选择关机时就不行
请问是什么原因
系统在重启时间程序成功
但系统选择关机时就不行
请问是什么原因
解决方案 »
- 继承控件tpanel的onenter事件问题
- 急啊!已经搞了二天了,却不知错在那里
- 输入法原来是中文,为什么当点到COMBOBOX框时会变成英文的。有什么属性可以设置吗?谢谢
- 超多IT书的网站 http://www.netyi.net/in.asp?id=netyi123456
- 外循环10万多次,内循环1万多次,如何加快速度啊?
- fastreport安装说明为乱码?
- DELPHI基础问题,在线等待回答
- 斑竹你难道真的不能同意吗?我已经发表了一次贴子,看看java版的计划把都放到标题上来了
- 请问:怎样固定图象的长宽比,将image控件适应屏幕显示?
- 怎样在DBGrid中获得选定的记录的NO。
- 如何结束一个进程的ID?在线等。。。
- 已经EOF了,为什么还能取得字段值?
我在窗体中加入一个复选框(CHECKBOX),如果不选中它,则无法关闭WIN9X,如果选中它,才可以关闭。你可以改成自己的需要处理方式试试!
unit Unit1; interface uses Windows, Messages, SysUtils,Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
private
{ Private declarations }
//声明拦截WM_QueryEndSession消息的过程
procedure WMQueryEndSession(var Msg: TMessage); message WM_QueryEndSession;
public
{ Public declarations }
end; var
Form1: TForm1; implementation
{$R *.DFM} procedure TForm1.WMQueryEndSession(var Msg: TMessage);
begin
if CheckBox1.Checked then
Msg.Result := 1
else
Msg.Result := 0;
end;
end.
if Win32Platform <> VER_PLATFORM_WIN32_NT then //不是NT
ExitWindowsEx(EWX_REBOOT, 0)
else
begin
SetPrivilege('SeShutdownPrivilege', True);
if not ExitWindowsEx(EWX_REBOOT + EWX_FORCE, 0) then
SetPrivilege('SeShutdownPrivilege', False);
end; //--关机
if Win32Platform <> VER_PLATFORM_WIN32_NT then //不是NT
ShellExecute(handle, 'open', 'RUNDLL32.EXE', 'user.exe,ExitWindows', nil, SW_ShowNormal)
else
begin
SetPrivilege('SeShutdownPrivilege', True);
if not ExitWindowsEx(EWX_SHUTDOWN + EWX_FORCE+EWX_POWEROFF, 0) then
SetPrivilege('SeShutdownPrivilege', False);
end;