用InitSystemShutDown以后关机可以,但电源不能关闭,怎样解决呀
还用ExitWindowsEX函数关机在2000下怎么用啊
看MSDN说要应用程序要有什么权限,但不会用
谢谢
还用ExitWindowsEX函数关机在2000下怎么用啊
看MSDN说要应用程序要有什么权限,但不会用
谢谢
解决方案 »
- 单文档程序如何在CMainFrame类和CView类同时响应同一个菜单单击的消息函数
- .ico是那个类封装的?//那个函数是设置.ico图标为透明色的函数?
- VC++中的OnSysCommand
- 请问创建类似VISTA的图片管理库的图片分类标签应该是怎么样的结构?
- 用CDialogBar窗体布局问题,并禁止其移动和改变大小
- vc++网络编程迷惑?
- VC COM组件想通过一个事件传递一个Safearray数组.如何传递?
- memset和memcmp函数的使用问题???
- 画图板中的油漆桶功能怎么实现的?
- 将CString类型的转换成Float类型,怎么转换
- 怎样得到指定IP的计算机名
- 如果得到指定IP的机器名
TOKEN_PRIVILEGES tkp;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
error("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)
error("AdjustTokenPrivileges");
// Shut down the system and force all applications to close.
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
error("ExitWindowsEx");先取得关机权限,再设置关机权限,成功则可以关机了。