程序执行后关掉所有正在执行的其他程序,然后自己重启?

macro_love 2002-10-08 04:02:19
在我程序中有一重启计算机的命令,当我执行它后,将所有正在运行的程序全部关掉,然后重启。怎样才能做到?现在我执行后,如有其他程序在运行,做了修改的话,总是会提示"内容已经修改,是否保存?",我不想有这样的提示,而让它自己关掉,不用保存,就像有些安装程序一样,执行完毕后关掉所有程序自己重启,怎样做到?
...全文
32 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
macro_love 2002-10-08
  • 打赏
  • 举报
回复
我没说清楚,因为我在FormClose中有东西要执行,所以在关机之前就必须要有WM_QUERYENDSESSION 消息,但EWX_FORCE 是不发此消息的,而且在Win2k中用AdjustToken得到关机权限后用EWX_FORCE后是会出错的
  • 打赏
  • 举报
回复
BOOL ExitWindowsEx(

UINT uFlags, // shutdown operation
DWORD dwReserved // reserved
);


Parameters

uFlags

Specifies 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 Remarks 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 Remarks 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 Remarks section. Windows 95: Security privileges are not supported or required.


dwReserved

Reserved; this parameter is ignored.



Return Values

If the function succeeds, the return value is nonzero.

我想你的意思能满足了,散分,谢谢
qxj 2002-10-08
  • 打赏
  • 举报
回复
你可以用强制关机呀.
角落的青苔 2002-10-08
  • 打赏
  • 举报
回复
ExitWindowsEx(EWX_FORCE,4); //强行关机
可以吗?

5,391

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧