Вам надо создать функцию как переменную, произвести её активацию и при вызове её произвести проверку на существование данной функции. Код ниже прилагаю, но для вас он может быть не совсем верным. Используйте для данных действий уже готовые средства FPC/Lazarus.
И, на всякий случай, проверку DPI так же желательно производить! Потому что на разных системах, программы могут работать по разному.
Google translate:
You need to create a function as a variable, activate it and when calling it, check for the existence of this function. I attach the code below, but it may not be entirely correct for you. Use ready-made FPC/Lazarus tools for these actions.
And, just in case, it is also advisable to check the DPI! Because on different systems, programs may work differently.
var
libShcore: HMODULE;
...
GetDpiForMonitor: function(hmonitor: HMONITOR; dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT; stdcall;
GetScaleFactorForMonitor: function(hmonitor: HMONITOR; out Scale: UINT): HRESULT; stdcall;
...
procedure SetProcPoint;
begin
...
libShcore := dlopen('Shcore.dll');
if libShcore <> LIB_ERROR then
begin
(GetDpiForMonitor) := dlsym(libShcore, 'GetDpiForMonitor');
(GetScaleFactorForMonitor) := dlsym(libShcore, 'GetScaleFactorForMonitor');
end
else begin
(GetDpiForMonitor) := nil;
(GetScaleFactorForMonitor) := nil;
end;
...
end;
procedure TestScale;
var
outX, outY: LongWord;
begin
...
if Assigned(GetScaleFactorForMonitor) then
if GetScaleFactorForMonitor(scrMonitor, outX) = S_OK then
scrScaleWindow := 100 / outx;
if (Assigned(GetDpiForMonitor)) and (outX = 100) then
if GetDpiForMonitor(scrMonitor, MDT_EFFECTIVE_DPI, outX, outY) = S_OK then
scrScaleWindow := 96 / outX;
...
end;
Товарищи разработчики FPC/Lazarus, внесите пожалуйста данную функцию в ваш код! Так же можете использовать код, что я скинул, он сделан по вашему подобию и думаю не составит труда внести изменения.
Google translate:
Comrades FPC/Lazarus developers, please add this function to your code! You can also use the code that I dropped, it is made in your likeness and I think it will not be difficult to make changes.