//提升进程令牌函数 function AdjustProcessPrivilege(ProcessHandle:THandle;Token_Name:Pchar):boolean; var Token:THandle; TokenPri:_TOKEN_PRIVILEGES; ProcessDest:int64; l:DWORD; begin Result:=False; if OpenProcessToken(ProcessHandle,TOKEN_Adjust_Privileges,Token) then begin if LookupPrivilegeValue(nil,Token_Name,ProcessDest) then begin TokenPri.PrivilegeCount:=1; TokenPri.Privileges[0].Attributes:=SE_PRIVILEGE_ENABLED; TokenPri.Privileges[0].Luid:=ProcessDest; l:=0; //更新进程令牌,成功返回TRUE if AdjustTokenPrivileges(Token,False,TokenPri,sizeof(TokenPri),nil,l) then Result:=True; end; end; end; // if AdjustProcessPrivilege(GetCurrentProcess,'SeShutdownPrivilege') then//提升权限 begin //showmessage('ok'); SetSystemPowerState(false,TRUE); //电脑进入睡眠状态 www.delphitop.com end else begin //showmessage('no'); end;