Search code examples
c++winapihbitmap

Can I delete a HBITMAP object created in another process?


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?


Solution

  • 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.