我用ExitWindowsEx(EWX_LOGOFF,0);不好用。
我记得在电脑报上有一个介绍:新建一个快捷方式,输入 Shell32.dll ...加入几个参数,可以实现关机。到底应该怎样办?

解决方案 »

  1.   

    不用EWX_LOGOFF,用
    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. 
      

  2.   

    Shell32.dll ? 可以关机吗?
      

  3.   

    rundll32 shell32.dll,SHExitWindowsEx (注销).
     rundll32 shell32.dll,SHExitWindowsEx1 (关机). rundll32 shell32.dll,SHExitWindowsEx 2 ( 重新启动电脑). 
      

  4.   

    在Windows2000下实现有困难,还是自写一个函数吧!在Win2000下:void ShutDown(UINT uEWXFlag)
    {
    TOKEN_PRIVILEGES tkp,tkpnewbutignored;
    HANDLE hdltokenhandle;
    LUID tmpluid;
    BOOL rc;
    DWORD lbufferneeded;
    HANDLE  hdlprocesshandle = GetCurrentProcess();
    rc = OpenProcessToken(hdlprocesshandle,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hdltokenhandle);
    rc = LookupPrivilegeValue("","SeShutdownPrivilege", &tmpluid);
    tkp.PrivilegeCount = 1;
    tkp.Privileges[0].Luid = tmpluid;
    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    rc = AdjustTokenPrivileges(hdltokenhandle,FALSE,&tkp,sizeof(tkpnewbutignored),&tkpnewbutignored, &lbufferneeded);
    ExitWindowsEx(uEWXFlag,0);
    }