/// <summary>
/// 删除系统菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void window_SourceInitialized(object sender, EventArgs e)
{
var window = (Window)sender;
var helper = new WindowInteropHelper(window);
IntPtr windowHandle = helper.Handle; //Get the handle of this window
IntPtr hmenu = GetSystemMenu(windowHandle, 0);
DestroyMenu(hmenu);
hmenu = IntPtr.Zero;
}
[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 = "DestroyMenu")]
private static extern bool DestroyMenu(IntPtr hmenu);
private const int MF_BYPOSITION = 0x0400;
private const int MF_DISABLED = 0x0002;
wpf 删除系统自带右键菜单