How Do I prevent User, Locking the System...............?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Appyks

    #1

    How Do I prevent User, Locking the System...............?

    How Do I prevent User from Locking the System?

    Obviously I can set following Windows registry value
    But it doesn’t serve my propose
    [HKEY_CURRENT_US ER\Software\Mic rosoft\Windows\ CurrentVersion\ Policies\System]
    "DisableLockWor kstation"=dword :00000001

    I need something as the code follows in here
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
            }
    
            void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
            {
                try
                {
                    if (e.Reason == SessionSwitchReason.SessionLock)
                    {
                        if (MessageBox.Show("Are you sure you want to lock", "Confirm", MessageBoxButtons.YesNo) == DialogResult.No  )
                        {
                            //?????
                            //Stop the User in here…
                            //?????
                        }
                    }
    
                }
                catch (Exception)
                {
                    throw new NotImplementedException();    
                }
                
            }
        }
    }

    Thank you
    Last edited by Frinavale; Oct 29 '10, 02:41 PM. Reason: Please post code in [code] ...[/code] tags. Added code tags.
Working...