重写DefWndProc事件 #region Window 消息捕获 const int WM_COPYDATA = 0x004A; public struct COPYDATASTRUCT { public IntPtr dwData; public int cbData; [MarshalAs(UnmanagedType.LPStr)] public string lpData; } [DllImport("user32")] public static extern bool C
捕获控制台(console)关闭事件: 1.Ctrl+C信号: 2.Ctrl+Break信号: 3.用户系统关闭Console时: 4.用户退出系统时: 5.系统将要关闭时: using System; using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; namespace ConsoleApplication2 { public delegate bool Console