Saturn said:
Yes I need to change screen resolution itself like from 1280 X 800 to
800 X 600.
I can read the resolutions through win API but can't write
If you any way to change please let me know
- thanks
I've searched through Google and the Windows API, and found that this
function can do the trick: ChangeDisplaySettings
http://msdn.microsoft.com/en-us/library/dd183411(VS.85).aspx
An article on how to use it I found here:
http://msdn.microsoft.com/en-us/library/ms812499.aspx
You could use the function itself easily, but building up the DEVMODE
struct seems to be very complex (note that I'm using the win32-api gem
for such tasks). In C, you only have to change the values of a DEVMODE
you want to change, but since you can't access a struct from within
Ruby, you have to build up the whole struct and then use Array#pack to
turn it into a string which you can pass into the WinAPI function.
That's no problem with easy structs like the POINT struct - just do [0,
0].pack('LL') - but I've never found out how to manage that with complex
ones, especially with ones containing other structs. If someone knows
how to simplify that (besides a C extension written for the
MSVC-compiled Ruby version), please let me know.
Marvin