首页
社区
课程
招聘
请教下API的问题,我想改变屏幕分辩率及颜色
2006-4-7 17:06 4939

请教下API的问题,我想改变屏幕分辩率及颜色

2006-4-7 17:06
4939
我有个游戏要256色模式才能运行,不过我的屏幕属性中,只有16位色和32位,所以我想编个软件来更改桌面分辩率有颜色,请问哪个API能做到,或是有类似软件及代码?

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
点赞0
打赏
分享
最新回复 (6)
雪    币: 217
活跃值: (99)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
dwing 1 2006-4-7 18:22
2
0
XP中可以修改程序运行的兼容性,在程序的属性中,如256色,640*480等等.
雪    币: 217
活跃值: (99)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
dwing 1 2006-4-7 18:24
3
0
ChangeDisplaySettings
The ChangeDisplaySettings function changes the settings of the default display device to the graphics mode specified in lpDevMode. To change the settings of a specified display device, use the ChangeDisplaySettingsEx function.

LONG ChangeDisplaySettings(
  LPDEVMODE lpDevMode,  
  DWORD dwflags         
);

Parameters
lpDevMode
Pointer to a DEVMODE structure that describes the graphics mode to switch to.
The dmSize member of DEVMODE must be initialized to the size, in bytes, of the DEVMODE structure.

The dmDriverExtra member of DEVMODE must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure.

In addition, you can use any or all of the following members of the DEVMODE structure. Member Meaning
dmBitsPerPel Bits per pixel
dmPelsWidth Pixel width
dmPelsHeight Pixel height
dmDisplayFlags Mode flags
dmDisplayFrequency Mode frequency
dmPosition  Windows 98, Windows NT 5.0 and later: Position of the device in a multi-monitor configuration

In addition to setting a value in one or more of the preceding DEVMODE members, you must also set the appropriate flags in the dmFields member. The flags indicate which members of the DEVMODE structure are used for the display settings change. If the appropriate bit is not set in dmFields, the display setting will not be changed. Set one or more of the following flags: Flag Meaning
DM_BITSPERPEL Use the dmBitsPerPel value.
DM_PELSWIDTH Use the dmPelsWidth value.
DM_PELSHEIGHT Use the dmPelsHeight value.
DM_DISPLAYFLAGS Use the dmDisplayFlags value.
DM_DISPLAYFREQUENCY Use the dmDisplayFrequency value.
DM_POSITION  Windows 98, Windows NT 5.0 and later: Use the dmPosition value.

If lpDevMode is NULL, all the values currently in the registry will be used for the display setting. Passing NULL for the lpDevMode parameter and 0 for the dwFlags parameter is the easiest way to return to the default mode after a dynamic mode change.

dwflags
Indicates how the graphics mode should be changed. May be one of the following: Flag Meaning
0 The graphics mode for the current screen will be changed dynamically.
CDS_UPDATEREGISTRY The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The mode information is stored in the USER profile.
CDS_TEST The system tests if the requested graphics mode could be set.  
CDS_FULLSCREEN The mode is temporary in nature.
Windows NT: If you change to and from another desktop, this mode will not be reset.

CDS_GLOBAL The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag.
CDS_SET_PRIMARY This device will become the primary device.  
CDS_RESET The settings should be changed, even if the requested settings are the same as the current settings.  
CDS_NORESET The settings will be saved in the registry, but will not take affect. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag.  

Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to that graphics mode.

If CDS_UPDATEREGISTRY is specified and it is possible to change the graphics mode dynamically, the information is stored in the registry and DISP_CHANGE_SUCCESSFUL is returned. If it is not possible to change the graphics mode dynamically, the information is stored in the registry and DISP_CHANGE_RESTART is returned.

Windows NT: If CDS_UPDATEREGISTRY is specified and the information could not be stored in the registry, the graphics mode is not changed and DISP_CHANGE_NOTUPDATED is returned.

Return Values
The ChangeDisplaySettings function returns one of the following values.

Value Meaning
DISP_CHANGE_SUCCESSFUL The settings change was successful.
DISP_CHANGE_RESTART The computer must be restarted in order for the graphics mode to work.
DISP_CHANGE_BADFLAGS An invalid set of flags was passed in.
DISP_CHANGE_BADPARAM An invalid parameter was passed in. This can include an invalid flag or combination of flags.
DISP_CHANGE_FAILED The display driver failed the specified graphics mode.
DISP_CHANGE_BADMODE The graphics mode is not supported.
DISP_CHANGE_NOTUPDATED Windows NT: Unable to write settings to the registry.

Remarks
To ensure that the DEVMODE structure passed to ChangeDisplaySettings is valid and contains only values supported by the display driver, use the DEVMODE returned by the EnumDisplaySettings function.

When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following message parameters:

Parameters Meaning
wParam New bits per pixel
LOWORD(lParam) New pixel width
HIWORD(lParam) New pixel height

QuickInfo
  Windows NT: Requires version 3.5 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.
雪    币: 212
活跃值: (40)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
aboil 2006-4-8 11:08
4
0
原来是这个函数,我还拼命以Setxxxxxx这样的函数,谢谢楼上
雪    币: 1852
活跃值: (504)
能力值: (RANK:1010 )
在线值:
发帖
回帖
粉丝
北极星2003 25 2006-4-8 20:41
5
0
我也记下了
雪    币: 1022
活跃值: (31)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
lingyu 1 2006-4-11 15:23
6
0
我找这函数好久了,收藏
雪    币: 212
活跃值: (40)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
Morpheus 2006-4-12 13:58
7
0
请教一个问题~一般游戏也是使用这个函数改变分辨率吗?

还有就是:

游戏界面: 800*600 全屏
我显示器最大支持: 1280*1024

我希望将该游戏窗口显示.

首先:
切出游戏,游戏窗口最小化
FindWindow 找到游戏窗口句柄
然后 ShowWindow(SW_NOMAL)(SW_SHOW游戏窗口没动静)游戏全屏800*600
Sleep(10000) 10秒以后

ChangeDisplaySettings,
MoveWindow(0,0,800,600).
发现无反应.

请问我这样实现有什么问题?

我猜想是游戏在切出的时候响应窗口最小化消息执行了一次
changedisplay,再show的时候再changedisplay一次!
所以我在进入游戏后等待10秒再changedisplay,同时给游戏窗口定位.
无用
游客
登录 | 注册 方可回帖
返回