是否可以在不重置剪贴板链的情况下中止进程而引起麻烦? [英] Can aborting a process without resetting the clipboard chain cause trouble?

查看:64
本文介绍了是否可以在不重置剪贴板链的情况下中止进程而引起麻烦?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,可以调用 SetClipboardViewer 在启动时注册剪贴板更改通知。在关闭时,它将调用 ChangeClipboardChain 正确地将自己从链中删除。

I've got a program that calls SetClipboardViewer at startup to register for clipboard change notifications. At shutdown time, it will call ChangeClipboardChain to remove itself from the chain correctly.

只要程序正常运行,这一切都很好。但是,这让我感到奇怪,如果程序中止了,或者是由于我在调试器下将其杀死,崩溃或者由于用户出了问题而导致用户终止了该程序,该怎么办?然后清理就永远不会发生。

This is all great as long as the program runs normally. But that's got me wondering, what happens if the program gets aborted, either by me killing it under the debugger, by a crash, or by the user killing the process because something went wrong? Then the cleanup never happens. Can that cause trouble for the system somehow?

具体来说,我知道Windows可以轻松删除查看器,因为它是一个句柄,并且Windows可以在进程终止时清理所有句柄,但这会导致我一直引用的链中下游的下一个值以某种方式丢失吗?

Specifically, I know Windows can remove my viewer without trouble because it's a handle and Windows can clean up all handles when a process terminates, but will this cause the next value downstream in the chain, that I was holding a reference to, to get lost somehow?

推荐答案

是的,如果无法将自己从链中移开,则会破坏链。致命罪恶#2。请阅读整个列表,以确保您遵守所有规则。
http://www.clipboardextender.com/developing -clipboard-aware-programs-for-windows / 6
许多应用程序都因此而受苦,包括Delphi IDE。也就是说,如果Delphi以某种方式崩溃,则它会杀死剪贴板链(无论如何是D2005)。

Yes, failure to remove yourself from the chain will break the chain. Deadly sin #2. Please read the whole list to be sure that you're following all of the rules. http://www.clipboardextender.com/developing-clipboard-aware-programs-for-windows/6 Lots of apps suffer from this, including the Delphi IDE. i.e. if Delphi crashes in certain ways, it'll kill the clipboard chain (D2005 anyway).

考虑在Vista / Windows7上使用Vista样式通知。

Consider using Vista style notification on Vista/Windows7.

这篇关于是否可以在不重置剪贴板链的情况下中止进程而引起麻烦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆