Private Shared SC_CLOSE As Integer = &HF060 Private Shared MF_BYCOMMAND As Integer = &H0 <DllImport("USER32.DLL")> _ Private Shared Function _ GetSystemMenu(ByVal argWnd As IntPtr, ByVal argRevert As Integer) As IntPtr End Function <DllImport("USER32.DLL")> _ Private Shared Function _ RemoveMenu(ByVal argMenu As IntPtr, ByVal argPosition As Integer, ByVal wFlags As Integer) As Integer End Function调用: Dim aoMenu As IntPtr = GetSystemMenu(Me.Handle, 0) RemoveMenu(aoMenu, SC_CLOSE, MF_BYCOMMAND)
添加代码:
e.cancel = true;
?
还有如何使得CTROL+C无效~,.Net控制台有点不爽~---------------------------------------------------------------------------------
屏蔽之。
如何把把关闭按钮变灰,能给出代码吗 多谢
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070212http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
Private Shared MF_BYCOMMAND As Integer = &H0 <DllImport("USER32.DLL")> _
Private Shared Function _
GetSystemMenu(ByVal argWnd As IntPtr, ByVal argRevert As Integer) As IntPtr
End Function <DllImport("USER32.DLL")> _
Private Shared Function _
RemoveMenu(ByVal argMenu As IntPtr, ByVal argPosition As Integer, ByVal wFlags As Integer) As Integer
End Function调用:
Dim aoMenu As IntPtr = GetSystemMenu(Me.Handle, 0)
RemoveMenu(aoMenu, SC_CLOSE, MF_BYCOMMAND)
private static extern int 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 int RemoveMenu(IntPtr hMenu, int nPos, int flags);
// // 用API安装事件处理
// static ConsoleCtrlDelegate newDelegate=new ConsoleCtrlDelegate(HandlerRoutine); /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{ //移除控制台窗口的关闭按钮*************************************************************** string fullPath=@""+System.Environment.CurrentDirectory+"\\Proxy.exe";
int WINDOW_HANDLER = FindWindow(null,fullPath);
IntPtr CLOSE_MENU=GetSystemMenu((IntPtr)WINDOW_HANDLER,IntPtr.Zero);
int SC_CLOSE=0xF060;
RemoveMenu(CLOSE_MENU, SC_CLOSE, 0x0);