如何获取剪贴板的独占访问权限以进行测试?
我有一个应用程序,长话短说,它使用剪贴板进行部分操作。
但有时,由于我从未 100% 确定的原因,有时剪贴板不可用。有时 RDC 客户端会阻止它,有时则不会。当你确实需要进行各种交易时,这是极难复制的之一。
是否可以编写一个小测试程序,在运行时不允许任何其他程序访问剪贴板?
I have an app which, long story short, uses the clipboard for part of its operation.
Sometimes though, for reasons I've never 100% nailed down, sometimes the clipboard isn't available. Sometimes the RDC client blocks it, sometimes it doesn't. And it's one of those extremely hard to reproduce when you really need to sorts of deals.
Could one write a little testing program that, while it runs, doesn't allow any other programs to access the clipboard?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想您可以调用 OpenClipboard 和 EmptyClipboard,然后只需将其保持打开状态,仅在测试应用程序退出时调用 CloseClipboard 或类似的操作...
从 SCHNAPPLE 编辑
所以这就是我本质上所做的,我发现 C# 代码可以在... 其他网站
I suppose you could call OpenClipboard, and EmptyClipboard, then simply keep it open and only call CloseClipboard when the testing application exits, or something like that...
EDIT FROM SCHNAPPLE
So this is what I did essentially and I found C# code to do it on... that other site
简单的解决方案可能是手动配置 RemDesk 以不监视剪贴板。这是 RemDesk 中的一个选项...
但是,是的,保持剪贴板打开应该会产生预期的效果,并且还会阻止将 WM_DrawClipboard 通知发送到剪贴板查看器。
The easy solution may be to just manually configure RemDesk to not monitor the clipboard. It's an option in RemDesk...
But yes, keeping the clipboard open should have the desired effect, and will also keep WM_DrawClipboard notifications from being sent to clipboard viewers.