VB Systeminformation object or similar API from VBA?

I am looking for a way to determine "SmallIconSize", which is described here:
but in VBA in stead of VB.  Is there some API that can be called to get this information?  Trying to figure out what size my system tray icons / NotifyIcons are (I have increased Windows DPI).  I understand I am to determine that from SmallIconSize, but the problem is I've got no idea how to get to it.
(No idea how hard this is, will increase points if needed.)
(I could of course just count pixels on my screen but I want to know how to do this in general.....)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can use either of the following:

Private Const SM_CXSMICON = 49
Private Const SM_CYSMICON = 50

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

'Debug.Print GetSystemMetrics(SM_CXSMICON)
'Debug.Print GetSystemMetrics(SM_CYSMICON)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Joe5Author Commented:
Awesome!  Thank you!

I accepted the solution already.  If you could also shed some more light on how to use the TB_GETBUTTONSIZE, that would be neat... I read it is a "message"?  How does one use that?
Sure... The message actually need to know the window handle of the system tray area (ToolbarWindow). It returns DWORD of the size of the buttons in the system tray area which you need to convert to two integer values for the width and heights. This might return 18x18 for example it's because there is 2pixel of seperation. Which means the actual icon is about 16x16.
Use like :  Call GetTrayButtonSize

Option Explicit

  LoWord      As Integer
  HiWord      As Integer
End Type

Private Const WM_USER = &H400&

Private Declare Function SendMessageW Lib "user32" ( _
  ByVal hWnd As Long, _
  ByVal wMsg As Long, _
  ByVal wParam As Long, _
  ByVal lParam As Long) As Long
Private Declare Function FindWindowExW Lib "user32" ( _
  ByVal hWnd1 As Long, _
  ByVal hWnd2 As Long, _
  ByVal lpsz1 As Long, _
  ByVal lpsz2 As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
  pDst As Any, _
  pSrc As Any, _
  ByVal ByteLen As Long)
Public Function FindWindow(ByVal hWnd As Long, ByVal szClass As String) As Long
  ' Finds a window handle if it exists.
  ' Returns the window handle.
  FindWindow = FindWindowExW(hWnd, 0, StrPtr(szClass), 0)
End Function

Public Sub GetTrayButtonSize()
  ' Get the system tray button size.
  Dim hWnd        As Long
  Dim dwResult    As Long
  Dim btnSize     As TRAYBUTTONSIZE
  hWnd = FindWindow(0, "Shell_TrayWnd")
  hWnd = FindWindow(hWnd, "TrayNotifyWnd")
  hWnd = FindWindow(hWnd, "SysPager")
  hWnd = FindWindow(hWnd, "ToolbarWindow32")

  dwResult = SendMessageW(hWnd, TB_GETBUTTONSIZE, 0, 0)
  If dwResult <> 0 Then
    CopyMemory btnSize, dwResult, LenB(btnSize)
    Debug.Print btnSize.LoWord
    Debug.Print btnSize.HiWord
  End If
End Sub

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Joe5Author Commented:
I am amazed to get this level of help.  Thank you!
Strangely, the TB_GETBUTTONSIZE code returns 30, 26 as the dimensions, while GetSystemMetrics says they are 20, 20.  The latter is more in line with what I had expected, so I will use that method.  (I am using Windows 7, by the way, don't know if that might have anything to do with the 30,26 result at all.)
Yup it works but the thing to remember is that it's not the actual size of the icon in the system tray but the size of the buttons in the system tray.. In Windows7 if you look close enough while hover your mouse over an icon you can see that the buttons height seems a bit larger then its width so this might indicate that the width is 26pixels and there is 3pixels of seperation from left to right and for the height there is 5 pixels of seperation from, top to bottom if the small icon size is 20x20.
Joe5Author Commented:
OK thanks :)  great help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.