Well, I did some research last night and discovered that Microsoft has been making a series of changes to how Windows manages adjustments (both manual and automatic) to DPI scaling since Windows 8.1. Automatic adjustments in scaling occurs when tablet users dock/undock to/from single or multi-monitor workstations, for example. Higher resolution monitors and displays also have made an impact on this issue. In later versions, Windows no longer requires a Logoff/Logon to make a scaling adjustment, but instead handles such changes on the fly.
There are many new API functions to support this new functionality. Apps can now individually manage DPI scaling themselves with this functionality.
A consequence of these changes is that the traditional method of asking Windows for DPI scaling information ALWAYS returns a value of 96 dots/logical inch, regardless of the actual setting. As I understand it, this was done so as not to break the zillions of existing Windows applications. This explains why Vlad consistently gets the results he does. I used Windows 7 OS to create the code I offered, which works as intended in that and in earlier versions of Windows.
It is not immediately clear how to use the new API functions to obtain the "real" DPI scaling that is in effect for an application. As usual, Microsoft doesn't do a great job of providing sample code. To add to the complexity, the functionality and the corresponding API set has evolved over several Windows releases, so some API's cannot be used prior to Win8.1 and others prior to Win10 (1607) and there may be some critical releases in between. Interrogation code will have to first determine the OS version and build in order to know what API's are available. Roland's OSVersion free code example on the TopWizProgramming web site will help some. It's not rocket science, but this will take some experimentation to figure out. It looks like the new GetDpiForSystem, GetDpiForMonitor and GetDpiForWindow API's and possibly others will need to be used.
I will work on this as my spare and evening time permits, but cannot make any promises when I will have a solution code that works across all versions of the Windows OS. Others are welcome and encouraged to come up with a solution.
John
I been looking into:
MonitorFromWindow ( https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfromwindow )
and then
GetScaleFactorForMonitor ( https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorformonitor )
but run into syntax issues.
Side note: These functions are excellent examples of where PowerScript "enum" NVOs come in handy for readable code.