.NET Framework不支持全局挂钩
除了WH_KEYBOARD_LL低级挂钩和WH_MOUSE_LL低级挂钩,您无法在Microsoft .NET Framework中实现全局挂钩.若要安装全局挂钩,挂钩必须具有本机DLL导出,才能将其自身插入另一个需要有效,一致的函数才能调用的进程中.此行为需要DLL导出. .NET Framework不支持DLL导出.托管代码不具有用于函数指针的一致值的概念,因为这些函数指针是动态生成的代理.
Global hooks are not supported in the .NET Framework
Except for the WH_KEYBOARD_LL low-level hook and the WH_MOUSE_LL low-level hook, you cannot implement global hooks in the Microsoft .NET Framework. To install a global hook, a hook must have a native DLL export to inject itself in another process that requires a valid, consistent function to call into. This behavior requires a DLL export. The .NET Framework does not support DLL exports. Managed code has no concept of a consistent value for a function pointer because these function pointers are proxies that are built dynamically.
推荐答案
没有检测粘贴事件的理想解决方案.就像RbMm所说的那样,仅当剪贴板中的内容更改时,才会发送WM_CLIPBOARDUPDATE. (复制或剪切). WM_DESTROYCLIPBOARD是在粘贴操作期间发送的,但前提是剪贴板中的内容是使用剪切操作添加的.
There is no ideal solution to detect paste event. Like RbMm said WM_CLIPBOARDUPDATE will be sent only when the content in the clipboard is changed. (copy or cut). WM_DESTROYCLIPBOARD is sent during a paste action but only if the content in the clipboard was added using a cut action.
但是您可以通过实现文件系统过滤器驱动程序来实现.
But you can achieve this by implementing a file system filter driver.
这篇关于C#使用HOOK检测剪贴板粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!