zoukankan      html  css  js  c++  java
  • Winfrom 定时锁屏

     #region 锁屏
            public struct LASTINPUTINFO
            {
                [MarshalAs(UnmanagedType.U4)]
                public int cbSize;
                [MarshalAs(UnmanagedType.U4)]
                public uint dwTime;
            }
            [DllImport("user32.dll")]
            public static extern bool GetLastInputInfo(ref    LASTINPUTINFO plii);
            public long getIdleTick()
            {
                LASTINPUTINFO vLastInputInfo = new LASTINPUTINFO();
                vLastInputInfo.cbSize = Marshal.SizeOf(vLastInputInfo);
                if (!GetLastInputInfo(ref    vLastInputInfo)) return 0;
                return Environment.TickCount - (long)vLastInputInfo.dwTime;
            }
            private void timer2_Tick(object sender, EventArgs e)
            {
                long i = getIdleTick() / 1000;
                if (i > 1200)//(i > 10 * 1000)//超过一分钟
                {
                    suoping();
                }
            }
            private void butsp_Click(object sender, EventArgs e)
            {
                suoping();
            }
            void suoping()
            {
                this.timer2.Enabled = false;
                frmpassword frm = new frmpassword();
                frm.ShowDialog();
                if (frm.DialogResult == DialogResult.OK)
                    this.timer2.Enabled = true;
                else
                    Application.ExitThread();
            }
            #endregion
  • 相关阅读:
    铁轨
    POJ 2385 -- Apple Catching
    POJ 3258 -- River Hopscotch
    POJ 1469 -- COURSES (二分匹配)
    POJ 2349 -- Arctic Network
    最小生成树
    NOIP200703守望者的逃离
    NOIP200706字符串的展开
    POJ 1036 -- Gangsters
    POJ 1952 -- BUY LOW, BUY LOWER
  • 原文地址:https://www.cnblogs.com/shuaimeng/p/10167125.html
Copyright © 2011-2022 走看看