Getting Screen Resolution in Windows with Ruby


#1

Hi, somebody knows how i can get Screen Resolution in Windows with Ruby
?
Anything stable please! And WinXp, Win98, Win95 compatible.

Cheers


#2

On 12/26/06, Felipe N. removed_email_address@domain.invalid wrote:

Hi, somebody knows how i can get Screen Resolution in Windows with Ruby ?
Anything stable please! And WinXp, Win98, Win95 compatible.

You can use the WIN32OLE library (or similar) to call the
GetSystemMetrics() function:
http://support.microsoft.com/kb/210603


#3

Thanks Wilson!

require ‘dl/import’
require ‘dl/struct’

SM_CXSCREEN = 0
SM_CYSCREEN = 1

user32 = DL.dlopen(“user32”)

get_system_metrics = user32[‘GetSystemMetrics’, ‘ILI’]
x, tmp = get_system_metrics.call(SM_CXSCREEN,0)
y, tmp = get_system_metrics.call(SM_CYSCREEN,0)

puts “#{x} x #{y}”