资源简介
通过windows API禁用、启用窗体的关闭按钮,防止不小心点击X号或右键关闭按钮而关闭程序

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace TestFormClose
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const int SC_CLOSE = 0xF060;
[DllImport(“User32.dll “ EntryPoint = “FindWindow“)]
private static extern IntPtr FindWindow(string lpClassName string lpWindowName);
[DllImport(“user32.dll“)]
static extern IntPtr GetSystemMenu(IntPtr hwnd bool bRevert);
[DllImport(“user32.dll “ EntryPoint = “RemoveMenu“)]
extern static int RemoveMenu(IntPtr hMenu int nPos int flags);
[DllImport(“user32.dll“)]
private static extern bool InsertMenu(IntPtr hMenu Int32 wPosition Int32 wFlags Int32 wIDNewItem string lpNewItem);
private void button1_Click(object sender EventArgs e)
{
IntPtr hwnd_win;
hwnd_win = FindWindow(null textBox1.Text);
IntPtr CLOSE_MENU = GetSystemMenu(hwnd_win false);
RemoveMenu(CLOSE_MENU SC_CLOSE 0x0);
}
private void button2_Click(object sender EventArgs e)
{
IntPtr hwnd_win = FindWindow(null textBox1.Text);
IntPtr CLOSE_MENU = GetSystemMenu(hwnd_win true);
InsertMenu(CLOSE_MENU SC_CLOSE 0x0 0 ““);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 338370 2013-06-07 08:55 TestFormClose\11.bmp
文件 404022 2013-06-07 08:56 TestFormClose\22.bmp
文件 9728 2013-06-07 08:53 TestFormClose\bin\Debug\TestFormClose.exe
文件 22016 2013-06-07 08:53 TestFormClose\bin\Debug\TestFormClose.pdb
文件 11608 2013-06-07 08:56 TestFormClose\bin\Debug\TestFormClose.vshost.exe
文件 490 2010-03-17 22:39 TestFormClose\bin\Debug\TestFormClose.vshost.exe.manifest
文件 1571 2013-06-07 08:52 TestFormClose\Form1.cs
文件 4508 2013-06-07 08:50 TestFormClose\Form1.Designer.cs
文件 5817 2013-06-07 08:50 TestFormClose\Form1.resx
文件 6104 2013-06-07 08:57 TestFormClose\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 470 2013-06-07 08:52 TestFormClose\obj\x86\Debug\GenerateResource-ResGen.read.1.tlog
文件 746 2013-06-07 08:52 TestFormClose\obj\x86\Debug\GenerateResource-ResGen.write.1.tlog
文件 927 2013-06-07 08:56 TestFormClose\obj\x86\Debug\TestFormClose.csproj.FileListAbsolute.txt
文件 9728 2013-06-07 08:53 TestFormClose\obj\x86\Debug\TestFormClose.exe
文件 180 2013-06-07 08:52 TestFormClose\obj\x86\Debug\TestFormClose.Form1.resources
文件 22016 2013-06-07 08:53 TestFormClose\obj\x86\Debug\TestFormClose.pdb
文件 180 2013-06-07 08:52 TestFormClose\obj\x86\Debug\TestFormClose.Properties.Resources.resources
文件 494 2013-06-07 08:46 TestFormClose\Program.cs
文件 1382 2013-06-07 08:46 TestFormClose\Properties\AssemblyInfo.cs
文件 2874 2013-06-07 08:46 TestFormClose\Properties\Resources.Designer.cs
文件 5612 2013-06-07 08:46 TestFormClose\Properties\Resources.resx
文件 1096 2013-06-07 08:46 TestFormClose\Properties\Settings.Designer.cs
文件 249 2013-06-07 08:46 TestFormClose\Properties\Settings.settings
文件 3578 2013-06-07 08:52 TestFormClose\TestFormClose.csproj
目录 0 2013-06-07 08:46 TestFormClose\obj\x86\Debug\TempPE
目录 0 2013-06-07 08:53 TestFormClose\obj\x86\Debug
目录 0 2013-06-07 08:53 TestFormClose\bin\Debug
目录 0 2013-06-07 08:46 TestFormClose\obj\x86
目录 0 2013-06-07 08:46 TestFormClose\bin
目录 0 2013-06-07 08:46 TestFormClose\obj
............此处省略5个文件信息
- 上一篇:qt自定义工具栏,类似word
- 下一篇:WIFI探针内核源码
相关资源
- 用友NC开发API字典
- AE开发Windows最短路径分析
- Web Api 通过文件流 文件到本地
- Spire API文档
- ectouch最新版JSAPI微信支付V3插
-
Windows em
bedded Compact 2013 应用开发调 - 黑苹果硬件兼容检测和查询软件
- Uninstall_Cortana_WINCLIENT.CN.rar
- Servlet API中文文档
- jstl-api-1.2和jstl-impl-1.2
- VMware65_SLP_DeLLSLIC2.1
- Windows异步套接字网络编程
- WINDOWS98启动盘镜像Win98.IMA
- 仿windows记事本
- hidusage.h hidpi.h 等USB开发用头文件
- windows7用的,非常漂亮的透明计时器
- OpenGL文档,api大全,可直接查询函数
- nVidia 控制面板 API
- IpHlpApi.h&IpHlpApi.lib
- windows下制作macOS安装U盘,绝对简单好
- keil vcom windows 7 64bit 驱动
- windows ce 系统的GPIO驱动程序
- TCP 发包工具(windows)
- 应用接口支持库1.1版eAPI
- 手机短信api接口(源代码)
- 微软的可以删除系统卸不干净的软件
- windows下生成MD5值的工具(WinMD5)
- windows cygwin ns2安装步骤
- 成都MAPINFO格式电子地图
- ATA(ATAPI)接口指令协议硬盘基础知识
评论
共有 条评论