试图通过物理监视器运行for循环,但句柄真的让我很困惑,我有伪代码,沿着以下行运行:
int tempCounter=0
for(counter = number of monitors;counter > 0;counter--){
RECT tempRECT;
HDC tempHDC;
Get resolution of DC handle (counter) -> tempRECT;
arrayList[tempCounter] = tempRECT;
Get virtual work area of DC handle (counter) -> tempRECT;
arrayList[tempCounter++] = tempRECT;
tempCounter++;
}
对于监视器的计数,GetSystemMetrics(80)是否足够可靠,或者是否有任何可能失败的异常?
我知道那里没有太多,但浏览MSDN让我一直在兜圈子,而且我在编程方面不是很称职。
它可以像这样简单:
#include <Windows.h>
#include <stdio.h>
BOOL CALLBACK MonitorEnumProc(
HMONITOR hMonitor,
HDC hdcMonitor,
LPRECT lprcMonitor,
LPARAM dwData
)
{
printf("%dx%dn", lprcMonitor->right, lprcMonitor->bottom);
}
int main(int argc, char*argv[]) {
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, 0);
}