获取屏幕分辨率和刷新率

1.Windows API方式:

DISPLAY_DEVICE displayDevice;

displayDevice.cb = sizeof(DISPLAY_DEVICE);
if (EnumDisplayDevices(NULL, adapter, &displayDevice,0))
{
DEVMODE devMode;
if (EnumDisplaySettings(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode))
{
info->iCurrentFPS = devMode.dmDisplayFrequency;
info->iWidth = devMode.dmPelsWidth;
info->iHeight = devMode.dmPelsHeight;
}

}


2.DirectX方式:

        D3DCAPS9 d3dCaps;
m_pd3d->GetDeviceCaps(adapter, D3DDEVTYPE_HAL, &d3dCaps);
D3DDISPLAYMODE displayMode;

m_pd3d->GetAdapterDisplayMode(adapter, &displayMode);

info->iMaxTextureWidth = d3dCaps.MaxTextureWidth;
info->iMaxTextureHeight = d3dCaps.MaxTextureHeight;
info->iCurrentFPS = displayMode.RefreshRate;
info->iWidth = displayMode.Width;
info->iHeight = displayMode.Height;

猜你喜欢

转载自blog.csdn.net/xiaoyafang123/article/details/79761405