我怎样才能从剪贴板通知?剪贴板、通知

2023-09-03 04:35:00 作者:长夜星河散去

有没有办法得到通知时的剪贴板内容发生了变化? 我看了一类剪贴板。它有许多方法来设置剪贴板中的内容,但任何情况下。

Is there a way to be notified when the content of the clipboard changes? I looked a class "Clipboard". It has numerous methods to set the clipboard content but no event.

推荐答案

有没有在框架,我相信。你可以使用Win32的做到这一点,虽然。看看 SetClipboardViewer user32.dll中:

There's nothing in the Framework, I believe. You can do it with Win32, though. Look into SetClipboardViewer in User32.dll:

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);

它变得有点复杂。这不是一个简单的通知,但消息间链;你需要通过通知到下一个接收器。

It gets a little involved. It isn't a straightforward notification, but a message chain; you'll need to pass the notification on to the next receiver.

本文有必要的步骤,一个很好的说明。

This article has a good description of the steps necessary.