使用EnumDisplayMonitors函数枚举,把下述代码放到模块中,在窗口里调用FillMonitorInfo即可看到效果(百度http://blog.到的,经测试可以运行)。
Option Explicit
Private Declare Function EnumDisplayMonitors Lib "user32.dll" (ByVal hdc As Long, ByVal lprcClip As Long, ByVal lpfnEnum As Long, ByVal dwData As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type RECTANGLE
LeftTopX As Long
LeftTopY As Long
RightDownX As Long
RightDownY As Long
End Type
Public Function FillMonitorInfo() As Integer
Call EnumDisplayMonitors(ByVal 0&, ByVal 0&, AddressOf EnumMonitor, ByVal 0&)
End Function
Public Function EnumMonitor(ByVal hMoinitor As Long, ByVal hdcMonitor As Long, lprcMonitor As Long, ByVal dwData As Long) As Long
Dim rcS As RECTANGLE
CopyMemory rcS, lprcMonitor, Len(rcS)
Debug.Print rcS.LeftTopX; rcS.LeftTopY; rcS.RightDownX - rcS.LeftTopX; rcS.RightDownY - rcS.LeftTopY; rcS.RightDownX; rcS.RightDownY
EnumMonitor = 1
End Function