添加引用:using System.Runtime.InteropServices;
public class Win32API
{
[DefaultDllImportSearchPaths(DllImportSearchPath.SafeDirectories)]
[DllImport("user32.dll")]
public static extern bool ChangeWindowMessageFilterEx(IntPtr HWnd, uint Msg, int WParam, IntPtr LParam);
}
添加引用:using System.Windows.Interop;
private IntPtr hwnd = IntPtr.Zero;
public const int WM_COPYDATA = 0x004A;
public const int MSGFLT_ALLOW = 0x0001;
public const int WM_QUERYENDSESSION = 0x11;
/// <summary>
/// Load事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
WindowInteropHelper wih = new Wind