using System.Runtime.InteropServices;
// …
[DllImport("user32.dll", EntryPoint="GetSystemMenu")]
private static extern IntPtr GetSystemMenu(IntPtr hwnd, int revert);
[DllImport("user32.dll", EntryPoint="GetMenuItemCount")]
private static extern int GetMenuItemCount(IntPtr hmenu);
[DllImport("user32.dll", EntryPoint="RemoveMenu")]
private static extern int RemoveMenu(IntPtr hmenu, int npos, int wflags);
[DllImport("user32.dll", EntryPoint="DrawMenuBar")]
private static extern int DrawMenuBar(IntPtr hwnd);
private const int MF_BYPOSITION = 0×0400;
private const int MF_DISABLED = 0×0002;
// …
IntPtr hmenu = GetSystemMenu(this.Handle, 0);
int cnt = GetMenuItemCount(hmenu);
// remove ‘close’ action
RemoveMenu(hmenu, cnt-1, MF_DISABLED | MF_BYPOSITION);
// remove extra menu line
RemoveMenu(hmenu, cnt-2, MF_DISABLED | MF_BYPOSITION);

Hi, i was searching for this this was what i searched for But i found a better solution and just wanted to let you know…
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
const int CS_NOCLOSE = 0×200;
cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE;
return cp;
}
}
By: Benjamin on November 19, 2007
at 2:09 pm