希望大家能给我点源代码看看..
谢谢.....

解决方案 »

  1.   

    The ExitWindowsEx function either logs off, shuts down, or shuts down and restarts the system. BOOL ExitWindowsEx(    UINT uFlags, // shutdown operation
        DWORD dwReserved  // reserved
       );
     ParametersuFlagsSpecifies the type of shutdown. This parameter must be some combination of the following values: Value Meaning
    EWX_FORCE Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
    EWX_LOGOFF Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
    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. Windows 95: Security privileges are not supported or required.
    EWX_REBOOT Shuts down the system and then restarts the system. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
    EWX_SHUTDOWN Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
     dwReservedReserved; this parameter is ignored.  Return ValuesIf the function succeeds, the return value is nonzero.
    If the function fails, the return value is zero. To get extended error information, call GetLastError.
      

  2.   

    使用API函数即可。
    WIN98适用:
    关机  ExitWindowsEx(EWX_FORCE or EWX_SHUTDOWN, 0)
    重启  ExitWindowsEx(EWX_REBOOT,0)
    注销  ExitWindowsEx(EWX_LOGOOFF,0)
      

  3.   

    EWX_SHUTDOWN Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. 
    注意:
    Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
    具体用法自己去查吧!
      

  4.   

    转贴.
    在Windows2000下关闭计算机function ShutDownSystem():BOOL;varhProcess,hAccessToken:THandle;LUID_AND_ATTRIBUTES:TLUIDAndAttributes;TOKEN_PRIVILEGES: TTokenPrivileges;BufferIsNull:DWORD;ConstSE_SHUTDOWN_NAME='SeShutdownPrivilege';beginhProcess:=GetCurrentProcess();OpenProcessToken(hprocess,TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY,hAccessToken);LookupPrivilegeValue(Nil,SE_SHUTDOWN_NAME,LUID_AND_ATTRIBUTES.Luid);LUID_AND_ATTRIBUTES.Attributes:=SE_PRIVILEGE_ENABLED;TOKEN_PRIVILEGES.PrivilegeCount:=1;TOKEN_PRIVILEGES.Privileges[0]:=LUID_AND_ATTRIBUTES;BufferIsNull:=0;AdjustTokenPrivileges(hAccessToken,False,TOKEN_PRIVILEGES,sizeof(TOKEN_PRIVILEGES),Nil,BufferIsNull);ExitWindowsEx(EWX_SHUTDOWN, 0);ShutDownSystem:=True;end;
      

  5.   

    Nt系统需要SeShutdownPrivilege权限