Ejemplo n.º 1
0
        public static bool IsScreenLocked()
        {
            var h = CGSessionCopyCurrentDictionary();

            if (h == IntPtr.Zero)
            {
                throw new ApplicationException("Not running within Quartz GUI session");
            }

            using (var d = new CFDictionary(h, true))
            {
                var kCGSSessionScreenIsLocked = new CFString("CGSSessionScreenIsLocked");
                var locked = CFDictionary.GetBooleanValue(d.Handle, kCGSSessionScreenIsLocked.Handle);
                return(locked);
            }
        }