The ExitWindowsEx function either logs off, shuts down, or shuts down and restarts the system. BOOL ExitWindowsEx( UINT uFlags, // shutdown operation
DWORD dwReserved // reserved
);
ParametersuFlagsSpecifies the type of shutdown. This parameter must be some combination of the following values: Value Meaning
EWX_FORCE Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
EWX_LOGOFF Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
EWX_POWEROFF Shuts down the system and turns off the power. The system must support the power-off feature.Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
EWX_REBOOT Shuts down the system and then restarts the system. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
EWX_SHUTDOWN Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
dwReservedReserved; this parameter is ignored. Return ValuesIf the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
DWORD dwReserved // reserved
);
ParametersuFlagsSpecifies the type of shutdown. This parameter must be some combination of the following values: Value Meaning
EWX_FORCE Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
EWX_LOGOFF Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
EWX_POWEROFF Shuts down the system and turns off the power. The system must support the power-off feature.Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
EWX_REBOOT Shuts down the system and then restarts the system. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
EWX_SHUTDOWN Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
dwReservedReserved; this parameter is ignored. Return ValuesIf the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
解决方案 »
- 如何将一个字符串转换为整形数组,经运算后再转换回字符串?
- 报表如何根据数据内容而自动进行分页显示??采用EXCEL模板
- 如何按照拼音查询
- 怎样让delphi中的panel透明
- Delphi程序,在xp下打印不出来的问题怎么解决?
- 在DELPHI中如何声明api函数!
- ★★★ ADSL端口映射问题,还请高手指点。如成功加300分
- 见者有份 急用 拜托了
- 请问:怎样判断notpad.exe是否运行,如果没有运行,则运行notpad.exe,如果notpad.exe 已经运行,则把notpad.exe 最大化,(注意:而不是
- 请教各位高手,怎样在Delphi中用语句自动创建表?
- 苦恼,不知到你们遇到没有?
- 怎样把一个汉字插入到一个字符串中,急,大家帮忙
begin
LookupPrivilegeValue(Nil ,'SeShutdownPrivilege' ,tkp.Privileges[0].Luid) ;
tkp.PrivilegeCount := 1;
tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken ,False ,tkp ,sizeof(tkp) ,otkp ,dwLen) ;
if (GetLastError() <> ERROR_SUCCESS) then
begin
ShowMessage('AdjustTokenPrivileges enable failed.') ;
end else
begin
ExitWindowsEx(EWX_REBOOT ,0) ;
end ;
end
我就是要重新启动我自己的程序,退出我自己的程序的登录。
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
WinExec(PChar('D:\Project1.exe'), 0);
end;