如何识别内部屏幕分辨率启用的多个显示?

时间:2014-03-06 09:58:24

标签: winapi cmd screen monitoring multiple-monitors

我在Google上搜索过但没有找到答案,所以如果有人知道那会非常感谢!

我想使用命令行或一些WinApi来检查多个显示的状态。 例如:如果我设置:“扩展屏幕”或“重复屏幕”,我希望能够验证它。 只是不知道从哪里开始。

非常感谢

1 个答案:

答案 0 :(得分:2)

我将从WinAPI EnumDisplayMonitors函数开始:http://msdn.microsoft.com/en-us/library/dd162610%28VS.85%29.aspx

BOOL EnumDisplayMonitors(
  _In_  HDC hdc,
  _In_  LPCRECT lprcClip,
  _In_  MONITORENUMPROC lpfnEnum,
  _In_  LPARAM dwData
);

您需要调用此函数将前2个参数设置为NULL,如下所示:

EnumDisplayMonitors(NULL, NULL, MyPaintEnumProc, 0);

//Enumerates all display monitors.
//The callback function receives a NULL HDC.

现在您拥有了MonitorEnumProc回调函数:http://msdn.microsoft.com/en-us/library/dd145061%28v=vs.85%29.aspx

BOOL CALLBACK MonitorEnumProc(
  _In_  HMONITOR hMonitor,
  _In_  HDC hdcMonitor,
  _In_  LPRECT lprcMonitor,
  _In_  LPARAM dwData
);

你将被lprcMonitor填满:

  

指向RECT结构的指针。       如果hdcMonitor为非NULL,则此矩形是由hdcMonitor标识的设备上下文的剪切区域的交集。   显示监视器矩形。矩形坐标是   设备上下文坐标。

If hdcMonitor is NULL, this rectangle is the display monitor rectangle. The rectangle coordinates are virtual-screen coordinates.

根据ALL监视器的这个值,您可以决定是否具有扩展模式(rects不同)或重复(它们是相同的)。

HTH - 祝你好运!