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

  • 相关阅读:
    JavaEE(9)
    微信公众平台自定义菜单接口API指南
    企业微信公众平台建设指南
    微信公众平台消息接口开发(13)多语种互译
    PHP 挖掘 XML 和 HTML 数据
    微信公众平台消息接口开发(12)消息接口Bug
    微信公众平台通用接口API指南
    微信公众平台消息接口API指南
    JavaEE(8)
    JavaEE(7)
  • 原文地址:https://www.cnblogs.com/answer/p/1617997.html
Copyright © 2011-2022 走看看