Sharing HDC between different processes

前端 未结 3 1842
独厮守ぢ
独厮守ぢ 2020-12-09 21:43

I am writing some kind of IPC functionality and need to pass certain resources from one process to another. This works well for Pipe handles etc. which can be duplicated via

3条回答
  •  [愿得一人]
    2020-12-09 21:53

    Assuming, that you want to paint onto a HDC belonging to one process from another process (e.g. by using BitBlt) then as pointed out by nobugz and Chris Becke you cannot share that HDC across process boundaries. But, further assuming that the HDC of that one process belongs to a window (and your intention is to finally draw onto that window) then you can pass that window handle to the other process and in this process use GetDc to obtain a HDC. With this HDC you can then paint onto the window of the other process.

提交回复
热议问题