惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
SegmentFault 最新的问题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Attack and Defense Labs
Attack and Defense Labs
F
Full Disclosure
Vercel News
Vercel News
N
News | PayPal Newsroom
The GitHub Blog
The GitHub Blog
H
Hacker News: Front Page
H
Heimdal Security Blog
P
Privacy International News Feed
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cisco Blogs
L
Lohrmann on Cybersecurity
D
Docker
Recent Announcements
Recent Announcements
Security Archives - TechRepublic
Security Archives - TechRepublic
人人都是产品经理
人人都是产品经理
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Proofpoint News Feed
T
Tailwind CSS Blog
C
Check Point Blog
博客园 - 叶小钗
Google Online Security Blog
Google Online Security Blog
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
S
Secure Thoughts
博客园 - Franky
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
P
Palo Alto Networks Blog
Latest news
Latest news
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
Last Week in AI
Last Week in AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cyberwarzone
Cyberwarzone
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
Hacker News: Ask HN
Hacker News: Ask HN
T
Threatpost
T
Tenable Blog
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学

博客园 - Peter Zhang

TF42064: The build number already exists for build definition error in TFS2010 模拟ORACLE wm_concat函数(把一列中的多行数据在一行显示) [转]重建损坏的Windows Management Instrumentation(WMI)服务 .NET 程序内存占用问题 存储过程锁问题、存储过程编译锁问题 ORA-00054错误解决方案 Oracle循环语句 【转】物化视图刷新 Oracle查询条件带有汉字时查询不出数据的原因 ORA-01658: 无法为表空间中段创建 INITIAL 区 Oracle未启用Partitioning功能 Oracle 表空间 Redmine running under Mongrel as windows service Redmine 插件安装 Redmine 如何使用版本库 Redmine 配置 Redmine EMAIL /SMTP 服务器设置 redmine svn:issuer is not trusted 问题的解决办法 redmine 1.2.1安装和安装会出现的问题
获取系统闲置时间
Peter Zhang · 2012-08-27 · via 博客园 - Peter Zhang
 
http://www.pinvoke.net/default.aspx/user32.GetLastInputInfo
[StructLayout(LayoutKind.Sequential)]
public struct LASTINPUTINFO
{
  [MarshalAs(UnmanagedType.U4)]
  public int cbSize;
  [MarshalAs(UnmanagedType.U4)]
  public uint dwTime;
}

static class NativeMethods
{
   /// <summary>
   /// 获取上一次输入的时间。
   /// </summary>
   /// <param name="plii"></param>
   /// <returns>true:获取成功。false:获取失败。</returns>
   [DllImport("user32.dll")]
   public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
   /// <summary>
   /// 获取上一次操作后的闲置时间。
   /// </summary>
   /// <returns>闲置时间的毫秒数。</returns>
    public static long GetIdleTick()
    {
         LASTINPUTINFO vLastInputInfo = new LASTINPUTINFO();
         vLastInputInfo.cbSize = Marshal.SizeOf(vLastInputInfo);
         if (!GetLastInputInfo(ref vLastInputInfo)) return 0;
         return Environment.TickCount - (long)vLastInputInfo.dwTime;
    }
}