INNO设置:如何获得主显示器的分辨率?

Vit*_*con 2 windows inno-setup

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

谢谢你的时间 :)

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

Vit*_*con 6

我的解决方案是使用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;
Run Code Online (Sandbox Code Playgroud)

编辑:似乎索引应该是SM_CXSCREEN和SM_CYSCREEN.更改了代码以反映这一点.