多春鱼小屋

登录
记住密码
  1. 首页
  2. 获取电脑系统空闲时间
获取电脑系统空闲时间
发布 | 2017-10-17 | 评论数:0 | 阅读数:4148 | 标签:Delphi
function GetLastInput: integer//获取闲置时间
var
  LInput: TLastInputInfo;
begin
  Result := 0;
  try
    LInput.cbSize := SizeOf(TLastInputInfo);
    GetLastInputInfo(LInput);
    Result := ((GetTickCount - LInput.dwTime) div 1000);
  except
  end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin
 if GetLastInput > 10 then
 Label1.Caption :='你已经'+ inttostr(GetLastInput) + '秒没有操作计算机了!'
 else
 Label1.Caption :='';
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
Label2.Caption :='电脑空闲时间:' + inttostr(GetLastInput) + '秒';
end;

分享至:

本文已关闭评论

  • 评论0
  • 粉丝1
  • 文章33

    • 多春鱼
    • 广州
    • 1970年2月26日
    • 联系 :capelin@qq.com 微信:imcapelin
    • 查看更多 >
    热门文章
    标签
    Delphi Android PHP Tools