禁用控制台的关闭按钮

复制代码
    class Program
    {
        [DllImport("user32.dll")]
        public static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);// 删除菜单

        [DllImport("user32.dll")]
        private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);// 获取系统菜单句柄

        [DllImport("kernel32.dll", ExactSpelling = true)]
        private static extern IntPtr GetConsoleWindow();// 获取控制台窗口句柄
        static void Main(string[] args)
        {
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), 0xF060, 0x00000000);
        }
    }
复制代码

 

posted @   超级驼鹿  阅读(29)  评论(0编辑  收藏  举报
/*
点击右上角即可分享
微信分享提示