Here is how to change your screen resolution programmatically. For doing this you may need the assistance of two APIs,- EnumDisplaySettings() - for getting the current graphics mode.
- ChangeDisplaySettings() - for setting the modified graphic mode.
Below code demonstrate changing your system screen resolution to 1280X1024.DEVMODE stGraphicsMode;
// Retrieves the information of current display device
EnumDisplaySettings ( NULL, 0, &stGraphicsMode );
// Change the screen resolution
stGraphicsMode.dmPelsWidth = 1280;
stGraphicsMode.dmPelsHeight = 1024;
stGraphicsMode.dmBitsPerPel = 32;
// Set the modifying items
stGraphicsMode.dmFields = DM_PELSWIDTH DM_PELSHEIGHT DM_BITSPERPEL;
// Change the display settings
if( DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettings( &stGraphicsMode, CDS_FULLSCREEN ))
{
//Successfully changed!
}
No comments:
Post a Comment