如何在 DPI 感知设置为 DPI_AWARENESS_CONTEXT_UNAWARE 的情况下创建进程 [英] How can I CreateProcess with DPI awareness set to DPI_AWARENESS_CONTEXT_UNAWARE

查看:45
本文介绍了如何在 DPI 感知设置为 DPI_AWARENESS_CONTEXT_UNAWARE 的情况下创建进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 C++ 应用程序,它在 Windows 10 上使用 CreateProcessA 打开其他应用程序.这些应用程序可能具有不同的 DPI 感知设置.

I have C++ application which opens other apps with CreateProcessA on Windows 10. These apps could have different settings for DPI Awareness.

所以问题是 - 我可以创建将 DPI Awareness 设置为 DPI_AWARENESS_CONTEXT_UNAWARE 的进程吗?

So the question is - can I create processes with DPI Awareness set to DPI_AWARENESS_CONTEXT_UNAWARE?

如果不是 - 那么也许我可以为已经创建的进程设置 DPI_AWARENESS_CONTEXT_UNAWARE?

If not - then perhaps I can set DPI_AWARENESS_CONTEXT_UNAWARE for the already created process?

UPD:我的应用程序生成应用程序,然后改变一个人的位置.如果它看起来是另一台具有不同 DPI 的显示器,则提供缩放值.

UPD: My application spawns the app and then changes one's position. And if it appears to be another monitor with different DPI then scaled values are supplied.

如果应用知道 DPI,则在移动完成后,尺寸会根据 WM_DPICHANGED 消息值发生变化.生成的应用程序可能具有不同的 DPI 感知模式.所以想法是为它们设置一种模式,并以相同的逻辑控制所有它们的位置和尺寸.

If the app is DPI awared then after the move completed the dimensions changed according WM_DPICHANGED message values. Spawned apps could have different DPI Aware modes. So idea was to set them one mode and control position and dimensions of all of them with same logic.

推荐答案

如果应用程序还没有清单,您可以使用 SetProcessDpiAwarenessContext 设置感知.另请检查 this.

If the app does not already have a manifest, you can use SetProcessDpiAwarenessContext to set the awareness. Also check this.

除非使用 CreateRemoteThread,在这种情况下,您可能会在强制应用不知道的内容时导致不兼容.

You cannot set the awareness on an existing app unless if injecting a remote thread with CreateRemoteThread, in which case you may cause incompatibilities when forcing something that the app is not aware of.

这篇关于如何在 DPI 感知设置为 DPI_AWARENESS_CONTEXT_UNAWARE 的情况下创建进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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