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 va
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;
EDIT: It seems the indices should've been SM_CXSCREEN and SM_CYSCREEN. Changed the code to reflect that.