16,550
社区成员
发帖
与我相关
我的任务
分享//---------------罗列系统支持的分辨率----------------------------
DEVMODE *lpDevMode;
lpDevMode=new DEVMODE;
int i=0;
CString Str[500];
CString str;
BOOL Result=EnumDisplaySettings(NULL,i,lpDevMode);
while(Result)
{
str.Format("%d",lpDevMode->dmPelsWidth);
lpDevMode=new DEVMODE;
Result=EnumDisplaySettings(NULL,++i,lpDevMode);
Str[i]=str;
}
delete lpDevMode;
for(int j=0;j<500;j++)
{
OutputDebugString(Str[i]);//显示横向像素值
}
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)
{
FARPROC EnumDisplayDevices;
HINSTANCE hInstUser32;
DISPLAY_DEVICE DispDev;
char szSaveDeviceName[32];
BOOL bRet = TRUE;
hInstUser32 = LoadLibrary("User32.DLL");
if (!hInstUser32) return FALSE;
// Get the address of the EnumDisplayDevices function
EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
if (!EnumDisplayDevices) {
FreeLibrary(hInstUser32);
return FALSE;
}
ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE));
DispDev.cb = sizeof(DISPLAY_DEVICE);
// After the first call to EnumDisplayDevices,
// DispDev.DeviceString is the adapter name
if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0)) {
lstrcpy(szSaveDeviceName, DispDev.DeviceName);
// After second call, DispDev.DeviceString is the
// monitor name for that device
EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);
lstrcpy(lpszMonitorInfo, DispDev.DeviceString);
} else {
bRet = FALSE;
}
FreeLibrary(hInstUser32);
return bRet;
}