[Migrated content. Thread originally posted on 21 March 2011]
We have a program that queries user32.dll to determine the computer's DPI settings, using the "GetDeviceCaps" function. The following code works fine when run with the 8.1.2.1 runtime, but gives a MAV when run with the version 9.0.0 runtime (compiled by the 8.1.2.1 compiler). The MAV occurs on the call to "ReleaseDC", and does not happen if you step over (skip) the line in the debugger, or if you comment that line out.
SET ENVIRONMENT "DLL_CONVENTION" TO "1"
CALL "USER32.DLL@WINAPI"
CALL "GetDC" Using BY VALUE hwnd GIVING hdc
CANCEL "user32.dll"
CALL "gdi32.dll"
CALL "GetDeviceCaps"
USING BY VALUE hdc
BY VALUE LOGPIXELSX
GIVING DPIX
END-CALL.
CALL "GetDeviceCaps"
USING BY VALUE hdc
BY VALUE LOGPIXELSY
GIVING DPIY
END-CALL.
CANCEL "gdi32.dll".
CALL "USER32.DLL@WINAPI"
CALL "ReleaseDC" Using BY VALUE hdc
CANCEL "user32.dll"



