怎么用程序关机呀?

解决方案 »

  1.   

    void ShutDown(void)
    {
     OSVERSIONINFO osv;
     osv.dwOSVersionInfoSize=sizeof OSVERSIONINFO;
     GetVersionEx(&osv);
     if(osv.dwPlatformId==VER_PLATFORM_WIN32_NT)
     {
      HANDLE hProcess,hToken;
      TOKEN_PRIVILEGES Privileges;
      LUID luid;
      hProcess=GetCurrentProcess();
      OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken);
      Privileges.PrivilegeCount=1;
      LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid);
      Privileges.Privileges[0].Luid=luid;
      Privileges.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
      AdjustTokenPrivileges(hToken,FALSE,&Privileges,NULL,NULL,NULL);
     }
     ExitWindowsEx(EWX_POWEROFF,0);
    }
    for win2000
      

  2.   

    2000如楼上所说,98下用ExitWindowsEx(EWX_POWEROFF,0);就可以了
      

  3.   

    补充一点,对于window nt(包括window2000,windows xp)还需要设置权限,具体,请查查msdn,就知道了。
      

  4.   

    http://www.csdn.net/cnshare/soft/12/12414.shtm//提供源代码
    我写的,很简单,参考一下