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?
Re: win32 help...
by $code or die (Deacon) on Sep 25, 2001 at 04:32 UTC
|
Check out Aldo Calpini's chres.pl. 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;
| [reply] |
|
| [reply] |
|
My link to chres.pl 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;
| [reply] |
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. | [reply] |
|
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.
—John
| [reply] |
|
Yes. HKLM isn't really used by MS on Win2k. I'm not sure, but I don't think XP uses it at all.
| [reply] |
|
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
______________________________________________
RIP
Douglas Noel Adams
1952 - 2001
| [reply] [d/l] |
|
|