WPF中监听剪贴板存在的Bug:OpenClipboard HRESULT:0x800401D0 (CLIPBRD_E_CANT_OPEN))错误
1.WPF监听剪贴板的方法
WPF的方法和WinForm略有不同,具体步骤如下:
(1)首先定义消息钩子
#region 消息钩子预定义参数
private const int WM_DRAWCLIPBOARD = 0x308;
private const int WM_CHANGECBCHAIN = 0x30D;
private IntPtr mNextClipBoardViewerHWnd;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static public extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static public extern bool ChangeClipboardChain(IntPtr HWnd, IntPtr HWndNext);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static