win32: fix GetDpiForMonitor SIGSEGV if Shcore is not available (e.g. on MS Windows Server 2012 R2)

git-svn-id: trunk@56180 -
This commit is contained in:
ondrej 2017-10-24 20:45:16 +00:00
parent a8df3d1f7d
commit 9823f61682

View File

@ -296,19 +296,18 @@ function InitShellScalingStubs: Boolean;
var
hShcore: Windows.HMODULE;
begin
if g_fShellScalingInitDone then
Exit(@g_pfnGetDpiForMonitor <> nil);
hShcore := GetModuleHandle('Shcore');
if hShcore<>0 then
if not g_fShellScalingInitDone then
begin
Pointer(g_pfnGetDpiForMonitor) := GetProcAddress(hShcore, 'GetDpiForMonitor');
hShcore := GetModuleHandle('Shcore');
if hShcore<>0 then
Pointer(g_pfnGetDpiForMonitor) := GetProcAddress(hShcore, 'GetDpiForMonitor')
else
Pointer(g_pfnGetDpiForMonitor) := nil;
g_fShellScalingInitDone := True;
end else
begin
Pointer(g_pfnGetDpiForMonitor) := nil;
end;
Result := (Pointer(g_pfnGetDpiForMonitor)<>nil) and (@g_pfnGetDpiForMonitor <> nil);
end;
function xGetDpiForMonitor(hmonitor: HMONITOR; dpiType: TMonitorDpiType;