Page 1 of 1 1
Topic Options
#130855 - 2004-12-08 10:28 PM How to find current display resolution
Ryan Dao Offline
Fresh Scripter

Registered: 2003-03-09
Posts: 45
Hi,

Where in the registry is the current display resolution?

Thanks

Top
#130856 - 2004-12-08 10:36 PM Re: How to find current display resolution
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
registry?
well, think it's there but you need to "decrypt" the info.
think you would be better of with something like:
http://www.gwspikval.com/jooel/UDF/udf/83000.htm
_________________________
!

download KiXnet

Top
#130857 - 2004-12-08 10:37 PM Re: How to find current display resolution
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

See our script monitor.kix on our site. Also some UDF's are available on UDF forum f.e. ScreenRes.
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#130858 - 2004-12-09 01:55 AM Re: How to find current display resolution
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Like MCA said screenres is a very good option. Is depends on WMI beeing installed.

For all workstations not having WMI installed we use the following to set the correct size company wallpaper. First a check which videoboard is installed because the last part of the reg key is different for most cards (even for just different driver versions) and then read the x and y reslolution.


Code:

;Read screen resolution for Nvidia Vanta cards
$resolutionx = ReadValue("HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\SERVICES\NV\DEVICE0", "DefaultSettings.XResolution")
$resolutiony = ReadValue("HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\SERVICES\NV\DEVICE0", "DefaultSettings.YResolution")
$resolution = $resolutionx + "x" + $resolutiony
;Checking if wallpaper exists
If Exist ("C:\WINNT\wallpaper" + $resolution + ".bmp") = 0
Shell "%COMSPEC% /E:1024 /C COPY " + @LDRIVE + "\wallpaper\" + "wallpaper" + $resolution + ".BMP C:\WINNT"
Else
$LOCAL = GetFileTime ("C:\WINNT\wallpaper" + $resolution + ".bmp")
$LOGON = GetFileTime (@LDRIVE + "\wallpaper\" + "wallpaper" + $resolution + ".BMP")
If ($LOCAL <> $LOGON)
Shell "%COMSPEC% /E:1024 /C COPY " + @LDRIVE + "\wallpaper\" + "wallpaper" + $resolution + ".BMP C:\WINNT"
EndIf

EndIf



This script is up for a revission soon so for example the comspec copy will be replaced with the kix copy function. Currently we are pushing WMI to all machines without WMI so Screenres() udf will be inplemented also.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#130859 - 2004-12-09 03:49 PM Re: How to find current display resolution
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I haven't bothered yet to peek in monitor.kix on MCA's site but I am pretty sure he uses something similar to this which will work on all cards :

Code:
$videokey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\"

$VidCard = enumkey("$videokey",0)
if @error=0
$video=$videokey+$VidCard+"\Device0"
$xres=readvalue("$video","DefaultSettings.XResolution")
$yres=readvalue("$video","DefaultSettings.YResolution")
else
$xres=640
$yres=480
endif



Edited by Jochen (2004-12-09 03:53 PM)
_________________________



Top
#130860 - 2004-12-09 04:10 PM Re: How to find current display resolution
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
except on my XP system where this key is absent.
_________________________
!

download KiXnet

Top
#130861 - 2004-12-09 04:17 PM Re: How to find current display resolution
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
hehe...

I'll rephrase it; "... which will work on all cards on Microsoft systems which have no WMI by default AND Windows 2000"
_________________________



Top
#130862 - 2004-12-09 05:22 PM Re: How to find current display resolution
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
you could also mean like:
"... which will work on all cards on Microsoft OPERATING systems"

that should remove XP-candy from the list
_________________________
!

download KiXnet

Top
#130863 - 2004-12-09 05:32 PM Re: How to find current display resolution
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Interesting ... is there such a key anywhere else in XP registry then?
Hmmm... now I am convinced; Need to setup an XPooP machine for research purposes
_________________________



Top
#130864 - 2004-12-09 08:59 PM Re: How to find current display resolution
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
This UDF will display the resolution of the Primary adapter on XP. Someone mind testing this on Windows 2000?

Code:
  
function resolution()
Dim $MSInfoDir, $MSInfo, $MSInfoTemp, $MSInfoResolution, $fh
$MSInfoDir='%commonprogramfiles%\Microsoft Shared\MSInfo\'
$MSInfo=$MSInfoDir + 'msinfo32.exe'
$MSInfoTemp=temp.txt
$MSInfoResolution=@scriptdir + '\resolution.txt'
if exist($MSInfoDir + $MSInfoTemp)
del $MSInfoDir + $MSInfoTemp
endif
if exist($MSInfoResolution)
del $MSInfoResolution
endif
shell '%comspec% /c "' + $MSINFO + '" /report ' + $MSInfoTemp + ' /categories +componentsdisplay'
shell '%comspec% /c type "' + $MSInfoDir + $MSInfoTemp + '" > "' + $MSInfoResolution + '"'
$fh=freefilehandle()
if open($fh,$MSInfoResolution)=0
$line=readline($fh)
while @error=0 and $found=0
if instr($line,"Resolution")
$resolution=ltrim(split($line,"Resolution")[1])
$found=1
endif
$line=readline($fh)
loop
$=close($fh)
endif
endfunction


Top
#130865 - 2004-12-09 09:20 PM Re: How to find current display resolution
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Al,

Code does not run properly for me on XP or 2003. Says
The system cannot find the file specified.

Top
#130866 - 2004-12-09 09:37 PM Re: How to find current display resolution
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Okay.. try now...

Code:
 

function resolution()
Dim $MSInfoDir, $MSInfo, $MSInfoTemp, $MSInfoResolution, $fh, $found
$MSInfoDir='%commonprogramfiles%\Microsoft Shared\MSInfo\'
$MSInfo=$MSInfoDir + 'msinfo32.exe'
$MSInfoTemp=temp.txt
$MSInfoResolution=@scriptdir + '\resolution.txt'
if exist($MSInfoDir + $MSInfoTemp)
del $MSInfoDir + $MSInfoTemp
endif
if exist($MSInfoResolution)
del $MSInfoResolution
endif
shell '%comspec% /c "' + $MSINFO + '" /report ' + $MSInfoTemp + ' /categories +componentsdisplay'
shell '%comspec% /c type "' + $MSInfoTemp + '" > "' + $MSInfoResolution + '"'
$fh=freefilehandle()
if open($fh,$MSInfoResolution)=0
$line=readline($fh)
while @error=0 and $found=0
if instr($line,"Resolution")
$resolution=ltrim(split($line,"Resolution")[1])
$found=1
endif
$line=readline($fh)
loop
$=close($fh)
endif
endfunction



Top
#130867 - 2004-12-09 09:45 PM Re: How to find current display resolution
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Al,

Code worked for me on the following systems.

XP/2000/2003

1280 x 1024 x 72 hertz
1024 x 768 x 60 hertz
1280 x 1024 x 72 hertz

Top
#130868 - 2004-12-09 10:17 PM Re: How to find current display resolution
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Okay... so the question is, does MSINFO32.exe depend on WMI?
Top
#130869 - 2004-12-09 10:25 PM Re: How to find current display resolution
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
... and unfortunately, it appears it does.

http://support.microsoft.com/?kbid=323209

Top
#130870 - 2004-12-09 11:08 PM Re: How to find current display resolution
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
FYI

I Tested MCA's MONITOR.KIX script and it worked on all systems tested.

NT 4.0 (no WMI)
2000 Server
XP w/SP2
2003 Server

This script is compatible with KiXtart v3.63 and was written back in 2001

http://home.wanadoo.nl/scripting/index-kix-scripts.htm

http://home.wanadoo.nl/scripting/download/monitor.kix

Top
#130871 - 2004-12-10 08:00 PM Re: How to find current display resolution
Ryan Dao Offline
Fresh Scripter

Registered: 2003-03-09
Posts: 45
Awesome...Thank you everyone for your help. I will try all suggestions then update.
Thanks again.

Ryan

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.071 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org