//declare this using System.Runtime.InteropServices; [return: MarshalAs(UnmanagedType.Bool)] [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern void BlockInput([In, MarshalAs(UnmanagedType.Bool)]bool fBlockIt); private void button1_Click(object sender, EventArgs e) { BlockInput(true); BlockInput(false); }