×

# C# 获取系统最后活动时间(已多久未活动)

hqy hqy 发表于2026-04-08 16:56:20 浏览5 评论0

抢沙发发表评论

# C# 获取系统最后活动时间(已多久未活动)

代码

C#
private LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();private void InitLastInputInfo(){    lastInputInfo.cbSize = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO));}private uint GetLastInputInfo(){    bool res = GetLastInputInfo(ref lastInputInfo);    if (res)    {        return (uint)Environment.TickCount - lastInputInfo.dwTime;    }    return 0;}[DllImport("user32.dll")]private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);[StructLayout(LayoutKind.Sequential)]struct LASTINPUTINFO{    public uint cbSize;    public uint dwTime;


打赏

本文链接:https://kinber.cn/post/6407.html 转载需授权!

分享到:


推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

 您阅读本篇文章共花了: 

群贤毕至

访客