大家帮我看看,为什么下面的不能实现关机啊,我是windows2000
procedure TForm1.Button1Click(Sender: TObject);
const
EWX_FORCE=4; //关闭所有程序并以其他用户身份登录
EWX_LOGOFF=0; //重新启动计算机并切换到MS-DOS方式
EWX_REBOOT=2; //重新启动计算机
EWX_SHUTDOWN=1;//关闭计算机
begin
ExitWindowsEx(EWX_SHUTDOWN,0);
end;
procedure TForm1.Button1Click(Sender: TObject);
const
EWX_FORCE=4; //关闭所有程序并以其他用户身份登录
EWX_LOGOFF=0; //重新启动计算机并切换到MS-DOS方式
EWX_REBOOT=2; //重新启动计算机
EWX_SHUTDOWN=1;//关闭计算机
begin
ExitWindowsEx(EWX_SHUTDOWN,0);
end;
解决方案 »
- getformimg 时候 combox 值空 什么原因
- 为什么不生效?---------xpmenu放在基类窗体!!!
- 在delphi中替换Word中的特殊标记,但只能替换一次
- 皮皮散分系列之五<流水>
- 关于indy的简单问题,来者有分
- FTP取得文件列表的问题 - 怎么正确的提取文件大小及时间?
- 在DELPHI编写代码的时候,如果感觉一行写的太长,想换行怎么办??
- 恭喜发财!龙马精神!过年了!:)~~~~~~
- 进来就有分,兄弟在想去上海,希望了解一下上海程序员的薪资情况,顺便了解一下你们的开发工具
- 模拟键盘击键(急!!!)
- 请教关于接口使用中出现的问题
- 谁有indy的中文开发资料。来者有分
begin
Result := True;
if (SetPrivilege('SeShutdownPrivilege',True)) then
begin
if(not ExitWindowsEx(iFlags,0))then
begin
Result := False;
end;
SetPrivilege('SeShutdownPrivilege',False)
end else begin
Result := False;
end;
end;function TTimeForm.SetPrivilege(sPrivilegeName: string; bEnabled: Boolean): Boolean;
var
TPPrev,TP: TTokenPrivileges;
Token: THandle;
dwRetLen: DWord;
begin
Result := False;
OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,Token);
TP.PrivilegeCount := 1;
if( LookupPrivilegeValue(Nil,PChar(sPrivilegeName),TP.Privileges[ 0 ].LUID )) then
begin
if(bEnabled) then
begin
TP.Privileges[ 0 ].Attributes := SE_PRIVILEGE_ENABLED;
end else begin
TP.Privileges[ 0 ].Attributes := 0;
end;
dwRetLen := 0;
Result := AdjustTokenPrivileges(Token,False,TP,SizeOf( TPPrev ),TPPrev,dwRetLen);
end;
CloseHandle(Token );
end;
if TeThemeRadioButton1.Checked then
WinExitInNT(EWX_SHUTDOWN);
if TeThemeRadioButton2.Checked then
WinExitInNT(EWX_REBOOT);原作者lukecjh