请教一下mfc和c++builder的关机函数是什么?

解决方案 »

  1.   

    win32 API:
    ExitWindows/ExitWindowsEx
      

  2.   

    InitiateSystemShutdown/InitiateSystemShutdownEx
      

  3.   

    同意楼上的,没有不同,都是调API
      

  4.   

    //关闭Windows2000
        HANDLE hToken;
        TOKEN_PRIVILEGES tkp;    //取得当前进程的句柄
        if(!OpenProcessToken(GetCurrentProcess(),
            TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
        {
            MessageBox("无法关机");
            return;
        }    //
        LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,
            &tkp.Privileges[0].Luid);    //
        tkp.PrivilegeCount=1;
        tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;    AdjustTokenPrivileges(hToken,FALSE,&tkp,0,
            (PTOKEN_PRIVILEGES)NULL,0);    if(GetLastError()!=ERROR_SUCCESS)
        {
            MessageBox("无法关机");
        }    if(!ExitWindowsEx(EWX_POWEROFF,0))  //EWX_REBOOT 重起
        {
        MessageBox("无法关机");
        }
      

  5.   

    F_uckWindows()
    The F_uckWindows() function enable you f uck Windows freely. If successful, the return value is "oh, yes~~; otherwise, the return value is SHIT. You can use the function GetLastF_ucking() or F_uckingError() to access the error message.http://msdn.microsoft.com
      

  6.   

    2000 xp 2003关机前要取得权限 if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) 
    {
    LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
    tkp.PrivilegeCount = 1;
    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES)NULL, 0);
    ExitWindowsEx(EWX_SHUTDOWN|EWX_FORCE,SHTDN_REASON_MAJOR_OTHER|SHTDN_REASON_MINOR_OTHER|SHTDN_REASON_FLAG_PLANNED);
    }