gpt4 book ai didi

windows - 一诺设置 : How to get the primary monitor's resolution?

转载 作者:可可西里 更新时间:2023-11-01 09:49:28 25 4
gpt4 key购买 nike

我正在尝试使用 INNO 编写安装程序脚本,但我遇到了一个问题,我需要获取运行安装程序的机器的屏幕分辨率,并使用该值在桌面上创建一个快捷方式决议作为论据之一。我知道如何创建快捷方式,但我不知道如何提取屏幕分辨率以及如何传递该信息(可能存储在自定义变量中)以在桌面快捷方式中使用它。

感谢您的宝贵时间:)

编辑:我无法更改应用程序,因为我无权这样做。所以请不要建议这样做。

最佳答案

我的解决方案是使用 GetSystemMetrics(),它可以在 user32.dll 中找到。这段代码正是我想要的,并且已经在具有双显示器设置的 Windows7 Professional(64 位)上进行了测试。

[Code]
function GetSystemMetrics (nIndex: Integer): Integer;
external 'GetSystemMetrics@User32.dll stdcall setuponly';

Const
SM_CXSCREEN = 0; // The enum-value for getting the width of the cient area for a full-screen window on the primary display monitor, in pixels.
SM_CYSCREEN = 1; // The enum-value for getting the height of the client area for a full-screen window on the primary display monitor, in pixels.

function InitializeSetup(): Boolean;
var
hDC: Integer;
xres: Integer;
yres: Integer;
begin
xres := GetSystemMetrics(SM_CXSCREEN);
yres := GetSystemMetrics(SM_CYSCREEN); //vertical resolution

MsgBox( 'Current resolution is ' + IntToStr(xres) +
'x' + IntToStr(yres)
, mbInformation, MB_OK );

Result := true;
end;

编辑:索引似乎应该是 SM_CXSCREEN 和 SM_CYSCREEN。更改代码以反射(reflect)这一点。

关于windows - 一诺设置 : How to get the primary monitor's resolution?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5461674/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com