怎样在计算机开机后两小时自动关机(两小时内一直在玩游戏

解决方案 »

  1.   

    web100(hello)说的简直是一派胡言,是没有根据的瞎想。我建议楼主用CMOS设置,就是一开机后进入DOS状态,设置CMOS里的一个定时关机选项, 具体是哪一个我忘记了。楼主如果英文好的话可以找的到的。
      

  2.   

    不用那么麻烦
    xp自带一个命令就可以自动关机
      shutdown 
    楼主 在命令提示符下面输入  shutdown /? 自己看看帮助
      

  3.   

    www.2ccc.com下载一个自动关机软件
      

  4.   

    du007(醉虾) 说:
    "我建议楼主用CMOS设置,就是一开机后进入DOS状态"----------------
    我倒......哈哈哈哈哈哈哈哈哈哈哈哈!!Basic I/O system 就是一开机进入dos状态?
      

  5.   

    to: du007(醉虾) ,不要随便说谁是一派胡言,1楼的思路基本正确,自动关机软件就是这么实现的.to:楼主,如果是win98或win2000,需要调用api,winXP有"shutdown"命令,按照 ghostmirror(BUPT)说的方法在XP的控制台下测试一下你就知道了.
      

  6.   

    procedure TForm1.AdjustToken();
    var
      hdlProcessHandle : Cardinal;
      hdlTokenHandle : Cardinal;
      tmpLuid : Int64;
      tkpPrivilegeCount : Int64;
      tkp : TOKEN_PRIVILEGES;
      tkpNewButIgnored : TOKEN_PRIVILEGES;
      lBufferNeeded : Cardinal;
      Privilege : array[0..0] of _LUID_AND_ATTRIBUTES;
    begin
             hdlProcessHandle := GetCurrentProcess;
             OpenProcessToken(hdlProcessHandle,
                             (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY),
                              hdlTokenHandle);         // Get the LUID for shutdown privilege.
             LookupPrivilegeValue('', 'SeShutdownPrivilege', tmpLuid);
             Privilege[0].Luid := tmpLuid;
             Privilege[0].Attributes := SE_PRIVILEGE_ENABLED;
             tkp.PrivilegeCount := 1;   // One privilege to set
             tkp.Privileges[0] := Privilege[0];
             // Enable the shutdown privilege in the access token of this
             // process.
             AdjustTokenPrivileges(hdlTokenHandle,
                                   False,
                                   tkp,
                                   Sizeof(tkpNewButIgnored),
                                   tkpNewButIgnored,
                                   lBufferNeeded); end;
    procedure TForm1.ShutDown;
    const
      SE_SHUTDOWN_NAME = 'SeShutdownPrivilege'; // Borland forgot this declaration
    var
      hToken : THandle;
      tkp : TTokenPrivileges;
      tkpo : TTokenPrivileges;
      zero : DWORD;
    begin
      if Pos( 'Windows NT', GetWinVersion) = 1 then // we've got to do a whole buch of things
      begin
        zero := 0;
        if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
        begin
          MessageBox( 0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK );
          Exit;
        end; // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)
        if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
        begin
          MessageBox( 0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK );
          Exit;
        end; // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)
        // SE_SHUTDOWN_NAME
        if not LookupPrivilegeValue( nil, 'SeShutdownPrivilege' , tkp.Privileges[ 0 ].Luid ) then
        begin
          MessageBox( 0, 'Exit Error', 'LookupPrivilegeValue() Failed', MB_OK );
          Exit;
        end; // if not LookupPrivilegeValue( nil, 'SeShutdownPrivilege' , tkp.Privileges[0].Luid )
        tkp.PrivilegeCount := 1;
        tkp.Privileges[ 0 ].Attributes := SE_PRIVILEGE_ENABLED;
        AdjustTokenPrivileges( hToken, False, tkp, SizeOf( TTokenPrivileges ), tkpo, zero );
        if Boolean( GetLastError() ) then
        begin
          MessageBox( 0, 'Exit Error', 'AdjustTokenPrivileges() Failed', MB_OK );
          Exit;
        end // if Boolean( GetLastError() )
        else
        ExitWindowsEx(  EWX_SHUTDOWN or EWX_POWEROFF, 0 );
      end // if OSVersion = 'Windows NT'
      else
      begin // just shut the machine down
        ExitWindowsEx( EWX_FORCE or EWX_SHUTDOWN, 0 );
      end; // else
    end;
    procedure TForm1.Button1Click(Sender: TObject);//关机
    begin
    AdjustToken();ShutDown
     //close;
    end;
    对以上程式稍加修饰就可实现定时关机
      

  7.   

    没有那么麻烦, 在你的程序中添加一个定时器, 并让你的程序随机器一起启动, 定时器定2小时, 在OnTimer事件中运行
    WinExec('rundll32.exe user.exe,exitwindows ');试试
      

  8.   

    WinExec('rundll32.exe user.exe,exitwindows ', 0);