WindowsFromDc return null

纵饮孤独 提交于 2019-12-07 11:09:00

问题


I need some help about the win32 api and especially WindowsFromDc.

I have a application which hook a another application. This two application communicate by a NamedPipe. In the second application, I have hook the DrawTextExW function and I get a HDC from this function.

But when I do a WindowsFromDC with the DC returned by the DrawTextEx function, i got a null return.

So, I have some question about that : -Is it possible a HDC don't have a HDWN with ? -How I can get the HWND of the window which call DrawTextEx ? There are other way do to that ?

Thank you.

Ps : Sorry for my bad english...


回答1:


Device context handles are not valid when passed cross-process. So what you are attempting to do is not possible.

As for your other questions:

Is it possible to have an HDC that is not associated with an HWND?

Yes that is perfectly possible. Plenty of device contexts are not associated with windows.

How I can get the HWND of the window which call DrawTextEx?

Windows do not call functions, code calls functions. So, the question does not really mean anything.



来源:https://stackoverflow.com/questions/16167880/windowsfromdc-return-null

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!