Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2021-03-03 09:09 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (76 votes). Check out past polls.