建一个模块,声明api Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type在form1中: Private Sub Command1_Click() Dim lpRect As RECT GetWindowRect FindWindow("Shell_TrayWnd", ""), lpRect MsgBox (lpRect.Bottom - lpRect.Top) End Sub
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type在form1中:
Private Sub Command1_Click()
Dim lpRect As RECT
GetWindowRect FindWindow("Shell_TrayWnd", ""), lpRect
MsgBox (lpRect.Bottom - lpRect.Top)
End Sub