我需要检测何时有人在整个系统中粘贴了一些东西。例如在记事本或 word 中不仅在 C# 应用程序中。我找到的示例仅描述了一些 WinForms 应用程序。
当我能够检测到该事件时,我想修改粘贴的值。
谢谢
最佳答案
要实现您的要求,您必须将您的应用程序注入(inject)系统上运行的所有其他窗口。该过程称为 Hook 。
摘自 How to set a Windows hook in Visual C# .NET
.NET Framework 不支持全局 Hook
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. Low-level hook procedures are called on the thread that installed the hook. Low-level hooks do not require that the hook procedure be implemented in a DLL.
什么是 Hooks :
A hook is a point in the system message-handling mechanism where an application can install a subroutine to monitor the message traffic in the system and process certain types of messages before they reach the target window procedure.
关于c# - 检测整个系统何时发生粘贴事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29546344/