INNO设置:如何获取主显示器的分辨率? [英] INNO Setup: How to get the primary monitor's resolution?

查看:120
本文介绍了INNO设置:如何获取主显示器的分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to script an installer with INNO and I am stuck at a point where I need to get the screen resolution of the machine in which the setup is running and use that value to create a shortcut in the desktop with that resolution as one of the arguments. I know how to create a shortcut, however I do not know how to extract the screen resolution and how to pass that information (probably stored in a custom variable) to use it in the desktop shortcut.

感谢您的时间:)

编辑:由于我无权执行此操作,因此无法更改该应用程序.因此,请不要建议这样做.

I cannot change the application because I'm not authorized to do that. So please do not suggest to do that.

推荐答案

对此,我的解决方案是使用GetSystemMetrics(),该文件可以在user32.dll中找到.这段代码为我提供了我想要的东西,并且已经在Windows7 Professional(64位)上使用双显示器设置进行了测试.

My solution to this was to use GetSystemMetrics(), which can be found in user32.dll. This piece of code gives me exactly what I want and has been tested on Windows7 Professional (64-bit) with a dual-monitor setup.

[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.更改了代码以反映这一点.

EDIT: It seems the indices should've been SM_CXSCREEN and SM_CYSCREEN. Changed the code to reflect that.

这篇关于INNO设置:如何获取主显示器的分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆