我可以删除在另一个进程中创建的 HBITMAP 对象吗?
我正在创建一个实用程序,它使用全局挂钩将一些(用户可自定义的)图标绘制到桌面上的其他窗口上。由于位图对象特定于进程,因此在绘制这些图标之前,我会在每个进程中为这些图标创建单独的 HBITMAP 对象,并且所有这些句柄都存储在 dll 中的共享段中。
现在,当(由用户)在我的程序中删除图标时,这些不同进程中该图标的所有 HBITMAP 对象都应被删除。我可以在主程序中使用DeleteObject() 来执行此操作,还是必须删除创建句柄的进程中的每个句柄?
I'm creating a utility program which draws some (user customizable) icons onto other windows on the desktop using a global hook. As bitmap objects are specific to a process, I'm creating separate HBITMAP objects for these icons in each process before I draw them, and all these handles are stored in a shared segment in the dll.
Now when an icon is removed in my program (by the user), all the HBITMAP objects for it in these different processes should be deleted. Can I do this using DeleteObject() in my main program or do I have to delete each handle in the process in which it was created?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然,您必须从创建它们的进程中删除它们 - 即使它对您有用,但对于不同的 Windows 版本可能不会。
Definitely you have to delete them from a process that created them - even if it works for you, for different windows version it might not.
GDI 对象的句柄通常是进程私有的。无论如何,您可以检查DeleteObject的返回值。
Handle to GDI Objects are normally private a process. You can check the return value of DeleteObject anyway.
我只是猜测这个...
您应该使用挂钩来挂钩到不同的窗口。
I'm just guessing this one...
you should use a hook, to hook to a different window.