Jump to content

GetDpiForMonitor


ExtremeGrief

Recommended Posts

Hello, does anyone know how to port GetDpiForMonitor to Windows 7? It's included in api-ms-win-shcore-scaling-l1-1-1.dll starting from WinBlue Windows 8.1 NT 6.3.9600. I need this DLL to run an app on Windows 7. It needed 2 functions, SetProcessDpiAwareness and GetDpiForMonitor. I already managed to port SetProcessDpiAwareness successfully but I'm stuck on GetDpiForMonitor... If some experienced user can help me I would be really thankful. Thanks!

Link to comment
Share on other sites


On 3/13/2022 at 1:24 AM, ExtremeGrief said:

Hello, does anyone know how to port GetDpiForMonitor to Windows 7? It's included in api-ms-win-shcore-scaling-l1-1-1.dll starting from WinBlue Windows 8.1 NT 6.3.9600. I need this DLL to run an app on Windows 7. It needed 2 functions, SetProcessDpiAwareness and GetDpiForMonitor. I already managed to port SetProcessDpiAwareness successfully but I'm stuck on GetDpiForMonitor... If some experienced user can help me I would be really thankful. Thanks!

For a quick and dirty solution to GetDpiForMonitor you can just set *dpiX and *dpiY both to 96, and return S_OK. Or, if you feel like doing it "properly" there are GDI functions you can use to get the real DPI for the system, which you can use instead.
As for SetProcessDpiAwareness, there's SetProcessDPIAware on Windows 7 - or you can just return a success code and do nothing. These DPI functions really don't matter too much if you have a normal (96 dpi or thereabouts) screen.

Link to comment
Share on other sites

5 hours ago, vxiiduu said:

For a quick and dirty solution to GetDpiForMonitor you can just set *dpiX and *dpiY both to 96, and return S_OK. Or, if you feel like doing it "properly" there are GDI functions you can use to get the real DPI for the system, which you can use instead.
As for SetProcessDpiAwareness, there's SetProcessDPIAware on Windows 7 - or you can just return a success code and do nothing. These DPI functions really don't matter too much if you have a normal (96 dpi or thereabouts) screen.

That is how I fixed the SetProcessDpiAwareness, I changed it to SetProcessDpiAware. Where should I do the edits for GetDpiForMonitor? 

Link to comment
Share on other sites

On 3/18/2022 at 4:12 PM, ExtremeGrief said:

That is how I fixed the SetProcessDpiAwareness, I changed it to SetProcessDpiAware. Where should I do the edits for GetDpiForMonitor? 

You just edited the PE import table? With like CFF explorer or something? That isn't a sustainable solution and it won't work for many functions. Which app are you trying to get running?

Edited by vxiiduu
Link to comment
Share on other sites

14 hours ago, vxiiduu said:

You just edited the PE import table? With like CFF explorer or something? That isn't a sustainable solution and it won't work for many functions. Which app are you trying to get running?

I used HxD. I am trying to get OpenConsole.exe from Microsoft Windows Terminal GitHub because Windows 7 Console Host sucks.

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...