I want to query the Windows display scaling setting programmatically:
In this case, I want it to return 125 since I configured my display to be at 125% scaling. According to this article, the following Windows API C++ code can be used:
// Get desktop dc
desktopDc = GetDC(NULL);
// Get native resolution
horizontalDPI = GetDeviceCaps(desktopDc,LOGPIXELSX);
verticalDPI = GetDeviceCaps(desktopDc,LOGPIXELSY);
However, this code always return 96 and 96 for the horizontal as well as vertical DPI which translates to 100% scaling (according to the provided table):

This output is wrong since I still get the same result with 125% scaling. How can it be done? I'm programming in Java so I can execute C++ using JNA. Windows API solutions are preferred but everything else like a .bat script or registry query is also fine as long as it's reliable for all Windows versions from 7 to 10.