zoukankan      html  css  js  c++  java
  • [转]使用API屏蔽掉控制台应用程序的关闭按钮

    using System;

    using System.Diagnostics;

    using System.Runtime.InteropServices;

    namespace ConsoleApplication3

    {

        class Program

        {

            [DllImport("user32.dll", EntryPoint = "FindWindow")]

            extern static IntPtr FindWindow(string lpClassName, string lpWindowName);

     

            [DllImport("user32.dll", EntryPoint = "GetSystemMenu")]

            extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert);

     

            [DllImport("user32.dll", EntryPoint = "RemoveMenu")]

            extern static IntPtr RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags); 

     

            static void closebtn()

            {

                IntPtr windowHandle = FindWindow(null, Process.GetCurrentProcess().MainModule.FileName);

                IntPtr closeMenu = GetSystemMenu(windowHandle, IntPtr.Zero);

                uint SC_CLOSE = 0xF060;

                RemoveMenu(closeMenu, SC_CLOSE, 0x0);

            }

            static void Main(string[] args)

            {

              closebtn();

                Console.WriteLine("Starting...");

                Console.Read();

            }

        }

    }


     来自:

     http://www.cnblogs.com/ylhome/archive/2009/05/17/1458864.html

  • 相关阅读:
    ASP.Net Core MVC+Ajax 跨域
    ASP.Net Core MVC 发生二次请求
    Spire高效稳定的.NET组件
    ASP.Net Core Razor+AdminLTE 小试牛刀
    二维码神器QRCoder
    读入 并查集 gcd/exgcd 高精度 快速幂
    Codeforces 348 D
    Gym
    BZOJ 3894 文理分科 最小割
    BZOJ 2132 圈地计划 最小割
  • 原文地址:https://www.cnblogs.com/answer/p/1617997.html
Copyright © 2011-2022 走看看