File OS2.INI
Application PM_DISPLAYDRIVERS
Key DEFAULTSYSTEMRESOLUTION
Value "xxxxyyyydddd????????"x
xxxx = horizontal resolution
yyyy = vertical resolution
dddd = color depth
???? = unknown value
(all values in LSB format)
Description contains the current
display resolution
Created ?
Deleted ?
File OS2.INI
Application PM_DISPLAYDRIVERS
Key RESOLUTION_CHANGED
Value "3100"x
Description display resolution change is
pending if this key exists
Created after changing the current resolution
using the System object
Deleted after the next reboot
Following is an example program using the known values of these entries to get the current display resolution.
/* ------------------------------------------------------------------ */ /* sample program to get the current display resolution */ /* */ /* load the necessary REXXUTIL function */ call rxFuncAdd "SysIni", "REXXUTIL", "SysIni" /* get the resolution */ parse value GetDisplayResolution() with , xResolution yResolution ColorDepth resolutionChangePending /* display the results */ say "Your current display resolution is " || , XResolution || "x" || YResolution || "x" || ColorDepth /* check if the resolution is already valid */ if resolutionChangePending = 1 then do say "" say "Note: You've changed the resolution but not rebooted until now." say " So maybe the resolution mentioned above is only valid after" say " the next reboot!" end /* if */ exit 0 /* ------------------------------------------------------------------ */ /* function: Get the current display resolution */ /* */ /* call: GetDisplayResolution */ /* */ /* returns: xValue yValue depth changePending */ /* */ /* where: xValue - horizontal size */ /* yValue - vertical size */ /* depth - colorDepth */ /* changePending - 1 : the resolution was changed but no */ /* reboot occurred until now */ /* 0 : the resolution is active */ /* */ /* note: unknown1 and unknown2 are unknown values in the INI file */ /* entry (see below). */ /* This routine needs the REXXUTIL function SYSINI and the */ /* subroutine LSB2MSB */ /* */ GetDisplayResolution: PROCEDURE /* init the return code */ parse value 0 0 0 0 with xValue yValue colorDepth changePending /* install a local error handler */ signal on syntax name GetDisplayValueError /* get the current resolution */ resolutionEntryInBin = SysIni( "USER" ,, "PM_DISPLAYDRIVERS" ,, "DEFAULTSYSTEMRESOLUTION" ) /* check, if a resolution change is pending */ resolutionChangePending = SysIni( "USER" ,, "PM_DISPLAYDRIVERS" ,, "RESOLUTION_CHANGED" ) if resolutionChangePending = "1" || "00"x then resolutionChangePending = 1 else resolutionChangePending = 0 /* convert the value into a hex string */ resolutionEntryInHex = c2x( resolutionEntryInBin ) parse var resolutionEntryInHex 1 xValue , 9 yValue , 17 ColorDepth , 25 unknown1 , 33 unknown2 /* convert the values into decimal values */ xValue = x2d( LSB2MSB( xValue ) ) yValue = x2d( LSB2MSB( yValue ) ) ColorDepth = x2d( LSB2MSB( ColorDepth ) ) /* not returned or used in this version */ unknown1 = x2d( LSB2MSB( unknown1 ) ) unknown2 = x2d( LSB2MSB( unknown2 ) ) /* this label is only used by the local error */ /* handler */ GetDisplayValueError: return xValue yValue colorDepth resolutionChangePending /* ------------------------------------------------------------------ */ /* function: Convert a WORD or DWORD from LSB format to MSB format */ /* and vice versa */ /* */ /* call: LSB2MSB inputHexString */ /* */ /* where: inputHexstring - input value as hexstring */ /* (e.g. "3412", "78563412") */ /* */ /* output: value in MSB format as hexstring */ /* (e.g. "1234", "12345678") */ /* */ LSB2MSB: PROCEDURE HexZiffer = arg(1) /* v3.00 */ Len = Length(HexZiffer) /* v3.00 */ If (Len // 2) then /* v3.00 */ HexZiffer = Right(HexZiffer, Len + 1, '0') /* v3.00 */ RETURN strip( translate( "12345678",, /* v3.00 */ HexZiffer, "78563412" ) ) /* v3.00 */