WIN2000下的关机问题?请高手们想想办法!

tester2000 2003-07-29 10:47:44
在电源选项中-》高级-》选择当按下电源按钮时-》关闭系统后,
当按下主机开关时,应用程序不能收到WM_QUERYENDSESSION消息。
(关机对话框中没有正在保存信息的字样)

我如何让我的程序在按下电源按键时得到这个WM_QUERYENDSESSION消息?
(在98中就没有这个问题)

另外,我在MSDN中查到以下资料:

Power Button on ACPI Computer May Force an Emergency Shutdown
PSS ID Number: Q297150

Article Last Modified on 05-13-2002


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Windows 2000, 2000 SP1 Server
Microsoft Windows 2000, 2000 SP1 Advanced Server
Microsoft Windows 2000, 2000 SP1 Professional

--------------------------------------------------------------------------------


Symptoms
If you install Windows 2000 on a computer whose BIOS is ACPI-compliant, when you press the power button on the computer, Windows performs an emergency shutdown and you do not have a chance to save your data before the computer shuts down.



Cause
When you press the power button, Windows performs an emergency shutdown, which means that Windows does not send the WM_QUERYENDSESSION and WM_ENDSESSION messages to the running programs. The programs therefore cannot notify the user to save data and quit gracefully.



Workaround



Status
This behavior is by design.

难道说这个问题无法解决?请高手们想想办法!

...全文
70 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhucde 2003-10-29
  • 打赏
  • 举报
回复
gz
lansefeng 2003-10-28
  • 打赏
  • 举报
回复
帮你up
tester2000 2003-10-28
  • 打赏
  • 举报
回复
自已UP一下先!再!再!
tester2000 2003-10-10
  • 打赏
  • 举报
回复
自已UP一下先!再!
feilaifenghf 2003-10-10
  • 打赏
  • 举报
回复
你肯定是用盗版的,换另外一个同版本系统重装一下试试!!!
tester2000 2003-09-26
  • 打赏
  • 举报
回复
唉!这么长时间也没人来。自已UP一下先!
yifengling0 2003-09-01
  • 打赏
  • 举报
回复
有些难度,关注,学习!
elyta 2003-08-30
  • 打赏
  • 举报
回复
我记得vchelp上有讲哦。很详细的。

关键问题在于取得关机的权限啊。
farfh 2003-08-26
  • 打赏
  • 举报
回复
闲下来看看高手的题目,呵呵,俺可不会写驱动,装个softice机子都当了,唉,现在都没法启动,郁闷啊,帮楼主up一下,hoho
tester2000 2003-08-23
  • 打赏
  • 举报
回复
楼上几位,请看清题目......
chenqsbeast 2003-08-18
  • 打赏
  • 举报
回复
同意:JOSENHUANG(阿磊)
xiaohedou 2003-08-14
  • 打赏
  • 举报
回复
study!
JOSENHUANG 2003-08-14
  • 打赏
  • 举报
回复
在2000下关机,需要调整用户的等级:
HANDLE hToken;
TOKEN_PRIVILEGES tkp;

if( (AfxMessageBox("Do you want to CLOSE WINDOWS? \n Y--Yes N--No",MB_ICONEXCLAMATION|MB_YESNO|MB_APPLMODAL))==IDYES)
{

// Get a token for this process.

if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
AfxMessageBox("OpenProcessToken !");

// Get the LUID for the shutdown privilege.

LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);

tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

// Get the shutdown privilege for this process.

AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0);

// Cannot test the return value of AdjustTokenPrivileges.

if (GetLastError() != ERROR_SUCCESS)
AfxMessageBox("AdjustTokenPrivileges !");

// Shut down the system and force all applications to close.
// you can restart the system too.
if (!ExitWindowsEx(EWX_POWEROFF|EWX_FORCE, 0))
AfxMessageBox("ExitWindowsEx !");
}
akiko 2003-08-14
  • 打赏
  • 举报
回复
up
tester2000 2003-08-08
  • 打赏
  • 举报
回复
继续想呀!我耐心等。。。。。。
XiangDong 2003-08-04
  • 打赏
  • 举报
回复
说不定可以从更下层考虑,既然win2000能受到Power Down消息,一定是会发出些中断之类的,能不能在电源管理的驱动程序上挂一个来获得这个消息?

呵呵,只是想法,我也不知道怎么实现。

newlife2002_313 2003-08-04
  • 打赏
  • 举报
回复
那估计就没辙了
good02xaut 2003-08-02
  • 打赏
  • 举报
回复
无奈!
tester2000 2003-08-02
  • 打赏
  • 举报
回复
up!
tester2000 2003-07-30
  • 打赏
  • 举报
回复
我就知道这个资料贴出来会让大家打退堂鼓......!@#$%!@$%?
加载更多回复(4)

2,640

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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