rt

解决方案 »

  1.   

    用findwindow获取任务栏的句柄,然后调用getwindowrect获得高度
      

  2.   

    Option Explicit
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End TypePrivate Sub Command1_Click()
        Dim hTrayWnd As Long, rc As RECT
        '注释: 获得任务栏的窗口句柄
        hTrayWnd = FindWindow("Shell_TrayWnd", vbNullString)
        
        GetWindowRect hTrayWnd, rc
        Debug.Print "The height is " & rc.Bottom - rc.Top
    End Sub