可能是程序开的比较多
然后执行这个函数就关不了机不过如果我把程序关的差不多了,还是可以的
我的是XP
具体写法是:ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF,0); 不知道有什么更好的方法吗?就是即使程序很多,最后还是能达到关机的目的

解决方案 »

  1.   

    在XP及03这样的系统中应该需要先提升权限吧,TokenPrivilege,AdjustTokenPrivilege等这几个函数
      

  2.   

    ExitWindowsEx
    The ExitWindowsEx function either logs off the current user, shuts down the system, or shuts down and restarts the system. It sends the WM_QUERYENDSESSION message to all applications to determine if they can be terminated. 
    //这里说到他将终止all applications During a shutdown or log-off operation, applications that are shut down are allowed a specific amount of time to respond to the shutdown request. If the time expires, the system displays a dialog box that allows the user to forcibly shut down the application, to retry the shutdown, or to cancel the shutdown request. If the EWX_FORCE value is specified, the system always forces applications to close and does not display the dialog box. 
    //这段说到他在固定时间内applications that are shut down are allowed 
    //一旦超时,会弹出一个对话跨能够进行选择强制关闭程序还是重试还是取消
    //当EWX_FORCE被设置时,系统会强制关闭 applications 原因可能就是因为程序多,超时了
    看看能不能把时间设置长点,不然就EWX_FORCE