陈宝刚---享受生活,追逐梦想!
理想是心中的火焰,有追求的人才是幸福的人!

加这个命名空间

using System.Runtime.InteropServices; 

[StructLayout(LayoutKind.Sequential)]
struct LASTINPUTINFO
{
[MarshalAs(UnmanagedType.U4)]
public int cbSize;
[MarshalAs(UnmanagedType.U4)]
public uint dwTime;
}
[DllImport("user32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
static long GetLastInputTime()
{
LASTINPUTINFO vLastInputInfo = new LASTINPUTINFO();
vLastInputInfo.cbSize = Marshal.SizeOf(vLastInputInfo);
if (!GetLastInputInfo(ref vLastInputInfo)) return 0;
return Environment.TickCount - (long)vLastInputInfo.dwTime;
}

posted on 2009-06-23 22:59  追梦人RUBY  阅读(335)  评论(0编辑  收藏  举报