Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

How to get screen resolution under Win32?

by Anonymous Monk
on Sep 25, 2001 at 03:17 UTC ( #114444=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

how can i get the screen resolution of a user's computer on a win32 system?
  • Comment on How to get screen resolution under Win32?

Replies are listed 'Best First'.
Re: win32 help...
by $code or die (Deacon) on Sep 25, 2001 at 04:32 UTC
    Check out Aldo Calpini's It gets\sets the screen settings.

    You probably already know this, but this method will not work in a CGI environment - i.e. you can't get the resolution of a remote user's screen via a webpage without a client-side script such as javascript. But I'm the wrong person to ask about that :)

    Update: Aldo's site appears to have changed since I was last there - and I can't find anything related to perl. The above URL is the same one listed for him on CPAN. ?

    Simon Flack ($code or die)
    $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
    =~y'_"' ';eval"die";print $_,lc substr$@,0,3;
      A simple Google...

      You can download Aldo's script here.

        My link to is ok - it's the link to Aldo's site that is the problem. :)

        And yes, I tried google for that too - the url is ok, it's the same one I've used many times - but his site is gone and without trace!

        Simon Flack ($code or die)
        $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
        =~y'_"' ';eval"die";print $_,lc substr$@,0,3;
Re: win32 help...
by CubicSpline (Friar) on Sep 25, 2001 at 04:06 UTC
    Look into the Win32-API module which allows you access to the windows registry. From there, look at HKEY_LOCAL_MACHINE\Config\0001\Display\Settings\Resolution.

    I may get down-voted for answering this, but it isn't exactly obvious and maybe someone else could benefit.

      Maybe it varies between Win32 OS's, because I see nothing remotely like that. No Config key under HKLM, and no Resolution key or named value with this information anywhere in the Registry.

      This is Windows 2000.


        Yes. HKLM isn't really used by MS on Win2k. I'm not sure, but I don't think XP uses it at all.
Re: How to get screen resolution under Win32?
by EvanK (Chaplain) on Sep 26, 2001 at 10:11 UTC
    $DesktopWin = $Main->GetDesktopWindow(); (undef,undef,$DesktopWidth,$DesktopHeight) = Win32::GUI::GetWindowRect +($DesktopWin); print "Screen Resolution is $DesktopWidth x $DesktopHeight";
    note: this requires use of the win32::gui module

    Douglas Noel Adams
    1952 - 2001

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://114444]
Approved by root
[stevieb]: LOL you can easily replace "Helsinki" with "Alberta"
[perldigious]: I used to live at the top of a very steep hill stevieb, I can relate to the video. Literally used to have to build up momentum and try to force my vehicle to make it up the hill to park in my driveway properly... didn't always make it.
[choroba]: Why don't they use tire chains?
[perldigious]: First snow, probably not prepared right away choroba.
[stevieb]: it's Quebec... they do weird stuff there :) In the mountains, it is *mandatory* for trucks to use tire chains. Many passenger vehicles do as well (but it's not mandatory for them)
[perldigious]: That stuff can hit fast... like what we just got where I'm at. Saw a few people who had slid OUT of the roundabout I have to drive through to get to work, not used to the ice yet, take awhile to get the hang of it again and make vehicle adjustments.
[stevieb]: man, when the roads are glare ice, I don't even bother going to work or out... unless I absolutely have to, or was already out in the first place
[choroba]: Tire chains are mandatory here in mountains, and the only unprepared each year are gritters
[stevieb]: I have a 3 day winter survival kit in my vehicle in the event I get snowed in in the mountains (which has happened before due to avalanches closing the roads (and once in the summer due to a massive forest fire that trapped us
[perldigious]: a handful of people in my work area did not make it, but I live pretty close and it's flat the whole way, so I didn't have any trouble. The roundabout is the worst thing I have to negotiate.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2016-12-06 16:36 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (112 votes). Check out past polls.