请教各位,如何控制局域网内的一台客户端关机????
也就是说,我在服务器端想关掉客户端的一台机器(类似于美萍),不知如何写这段代码!用DELPHI实现!

解决方案 »

  1.   

    http://www.swissdelphicenter.ch/torry/showcode.php?id=168
      

  2.   

    http://www.3lsoft.com/download/info/929.htm
    ----------------DELPHI的------------------
    {********************重启,关机,强力关机,注销********************}
    function Irc_Reboot_Shutdown(i:integer):boolean;
    var
    hToken :THandle;
    tkp : TOKEN_PRIVILEGES;
    ReturnLength : DWord;
    begin
    RESULT:=false;
    if (not OpenProcessToken(GetCurrentProcess(),
    TOKEN_ADJUST_PRIVILEGES
    or TOKEN_ALL_ACCESS
    or TOKEN_QUERY, hToken))
    then
    RESULT:=false;
    LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);
    tkp.PrivilegeCount := 1;
    tkp.Privileges[0].Attributes :=SE_PRIVILEGE_ENABLED;
    ReturnLength :=0;
    AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil,ReturnLength);if (GetLastError() <> ERROR_SUCCESS) then
    RESULT:=false;
    case i of
    1: begin
    ExitWindowsEx(EWX_REBOOT, 0); //reboot
    RESULT:=true;
    end;
    2: begin
    ExitWindowsEx(EWX_SHUTDOWN, 0); //shutdown
    RESULT:=true;
    end;
    3: begin
    ExitWindowsEx(EWX_FORCE+EWX_SHUTDOWN, 0); //force shutdown
    RESULT:=true;
    end;
    4: begin
    ExitWindowsEx(EWX_LOGOFF, 0); //logoff
    RESULT:=true;
    end;
    end;end; 
      

  3.   

    http://mblogger.cn/coolslob/posts/21110.aspx