WIN32 API编程--枚举系统显示器

#include <conio.h>
#include <stdio.h>
#include <windows.h>

BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor,HDC hdcMonitor,LPRECT lprcMonitor,LPARAM dwData)
{
 MONITORINFOEX mi;
 mi.cbSize=sizeof(MONITORINFOEX);
 GetMonitorInfo(hMonitor,&mi);
 printf("Device name:%s\t",mi.szDevice);
 if(mi.dwFlags==MONITORINFOF_PRIMARY) printf("Primary monitor!\n");
 else printf("\n");
 printf("Monitor rectangle:(%d,%d,%d,%d)\n",mi.rcMonitor.left,mi.rcMonitor.top,mi.rcMonitor.right,mi.rcMonitor.bottom);
 printf("Work rectangle:(%d,%d,%d,%d)\n",mi.rcWork.left,mi.rcWork.top,mi.rcWork.right,mi.rcWork.bottom);
 return true;
}

int main(void)
{
 EnumDisplayMonitors(NULL,NULL,MonitorEnumProc,NULL);
 getch();
 return 0;
}

posted @ 2005-12-23 12:13  Max Woods  阅读(1197)  评论(0编辑  收藏  举报