获取电脑多屏显示器分辨率

#include "stdafx.h"

#include<windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
    int  i;
    int monitorNum;
    BOOL flag;
    DISPLAY_DEVICE dd,dd1;

    i = 0;
    flag = true;

    DEVMODE dm;

    do
    {
        ZeroMemory(&dm, sizeof(dm));
        dm.dmSize = sizeof(dm);

        ZeroMemory(&dd, sizeof(dd));
        dd.cb = sizeof(dd);

        ZeroMemory(&dd1, sizeof(dd1));
        dd1.cb = sizeof(dd1);

        flag = EnumDisplayDevices(NULL, i, &dd, 0);
        if(!flag )
            break;

        printf("name is %s\n",dd.DeviceName);
        printf("DeviceString is %s\n",dd.DeviceString);
        EnumDisplayDevices(dd.DeviceName, 0, &dd1, 0);
        printf("dd1 is %s\n",dd1.DeviceString);

        printf("DISPLAY_DEVICE_ATTACHED_TO_DESKTOP is %d\n",dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP);
        EnumDisplaySettings(dd.DeviceName,ENUM_CURRENT_SETTINGS, &dm);
        printf("width is %d,height is %d \n",dm.dmPelsWidth,dm.dmPelsHeight);
        printf("\n\n");
        //printf("find\n");

        if (flag) i += 1;

    } while (flag);

    monitorNum = i;  // 总数量
    printf("SM_CMONITORS is %d;monitorNum is %d\n", GetSystemMetrics(SM_CMONITORS) ,monitorNum);

    return 0;
}
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页