GetSystemMetrics Function

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

Platforms: Win 32s, Win 95/98, Win NT

GetSystemMetrics returns information about various things in Windows. Most of these deal with the sizes of various objects, such as the screen, icons, cursors, etc. This function provides information about the system. The return value of the function depends on the value specified for nIndex. Keep in mind that all sizes (such as widths and heights) are measured in pixels. Also note that some of the metrics have slightly different meanings between Win NT and Win 95/98.

nIndex
Exactly one of the following flags specifying which piece of information to return:
SM_ARRANGE = 56
Win 95/98 only: Return the method used to display minimized windows. The return value is a combination of two of the following flags, one specifying a starting position for the minimized icons and another specifying the direction in which new ones are added:
ARW_BOTTOMLEFT = 0
Start placing the icons in the bottom-left corner of the screen.
ARW_BOTTOMRIGHT = 1
Start placing the icons in the bottom-right corner of the screen.
ARW_DOWN = 4
Add new icons below existing ones.
ARW_HIDE = 8
Do not place the icons anywhere on the screen (i.e., hide them).
ARW_LEFT = 0
Add new icons to the left of existing ones.
ARW_RIGHT = 4
Add new icons to the right of existing ones.
ARW_STARTRIGHT = 1
Same as ARW_BOTTOMRIGHT.
ARW_STARTTOP = 2
Same as ARW_TOPLEFT.
ARW_TOPLEFT = 2
Start placing the icons in the top-left corner of the screen.
ARW_TOPRIGHT = 3
Start placing the icons in the top-right corner of the screen.
ARW_UP = 0
Add new icons above existing ones.
SM_CLEANBOOT = 67
Win 95/98 only: Return a value specifying how the computer was booted up. 0 means a normal bootup, 1 means a fail-safe (a.k.a. SafeBoot) bootup, and 2 means a fail-safe bootup with the network installed.
SM_CMETRICS = 44
Win 95/98 only: Return the number of system metrics.
SM_CMOUSEBUTTONS = 43
Return the number of mouse buttons on the installed mouse, or 0 if no mouse is installed.
SM_CXBORDER = 5
Win NT: Return the width of a window border. Win 95/98: Return the width of a single window border.
SM_CXCURSOR = 13
Win NT: Return the width of the cursor. Win 95/98: Return the width of the standard cursor bitmap.
SM_CXDLGFRAME = 7
Win NT only: Return the width of a window frame having a dialog frame style.
SM_CXDOUBLECLK = 36
The width of the rectangle within which both mouse clicks must be to recognize a double-click.
SM_CXDRAG = 68
Return the minimum width the cursor must move to begin a drag-and-drop operation.
SM_CXEDGE = 45
Win 95/98 only: Return the width of a 3D window border.
SM_CXFRAME = 32
Win NT only: Return the width of the border of a resizable window.
SM_CXFULLSCREEN = 16
Return the width of the client area of a full-screen window.
SM_CXHSCROLL = 21
Win 95/98 only: Return the width of an arrow bitmap on a horizontal scrollbar.
SM_CXHTHUMB = 10
Return the width of the horizontal scrollbar thumb.
SM_CXICON = 11
Return the default width of an icon.
SM_CXICONSPACING = 38
Win NT: Return the width of the cell used to position icons. Win 95/98: Return the width of the grid cell for items in a large icon view.
SM_CXMAXIMIZED = 61
Win 95/98 only: Return the default width of a maximized window.
SM_CXMAXTRACK = 59
Win 95/98 only: Return the default maximum width the user is allowed to resize a window to.
SM_CXMENUCHECK = 71
Win 95/98 only: Return the width of the default menu check-mark bitmap.
SM_CXMENUSIZE = 54
Win 95/98 only: Return the width of a menu bar button.
SM_CXMIN = 28
Return the minimum width of a window.
SM_CXMINIMIZED = 57
Win 95/98 only: Return the width of a normal minimized window.
SM_CXMINSPACING = 47
Win 95/98 only: Return the width of the grid cell rectangle used to position minimized windows.
SM_CXMINTRACK = 34
Win 95/98 only: Return the default minimum width the user is allowed to resizea window to.
SM_CXSCREEN = 0
Return the width of the screen.
SM_CXSIZE = 30
Win NT: Return the width of a title bar bitmap. Win 95/98: Return the width of a caption button.
SM_CXSIZEFRAME = 32
Win 95/98 only: Return the width of a thick window frame.
SM_CXSMICON = 49
Win 95/98 only: Return the recommended width for small icons.
SM_CXSMSIZE = 52
Win 95/98 only: Return the width of a small caption button.
SM_CXVSCROLL = 2
Win 95/98 only: Return the width of a vertical scrollbar.
SM_CYBORDER = 6
Win NT: Return the height of a window border. Win 95/98: Return the height of a single window border.
SM_CYCAPTION = 4
Return the height of a normal caption area.
SM_CYCURSOR = 14
Win NT: Return the height of the cursor. Win 95/98: Return the height of the standard cursor bitmap.
SM_CYDLGFRAME = 8
Win NT only: Return the height of a window frame having a dialog frame style.
SM_CYDOUBLECLK = 37
Return the height of the rectangle within which both mouse clicks must be to recognize a double-click.
SM_CYDRAG = 69
Return the minimum height the cursor must move to begin a drag-and-drop operation.
SM_CYEDGE = 46
Win 95/98 only: Return the height of a 3D window border.
SM_CYFRAME = 33
Win NT only: Return the height of the border of a resizable window.
SM_CYFULLSCREEN = 17
Return the height of the client area of a full-screen window.
SM_CYHSCROLL = 3
Win 95/98 only: Return the height of a horizontal scrollbar.
SM_CYICON = 12
Return the default height of an icon.
SM_CYICONSPACING = 39
Win NT: Return the height of the cell used to position icons. Win 95/98: Return the height of the grid cell for items in a large icon view.
SM_CYKANJIWINDOW = 18
Return the height of the Kanji window (for double-byte character set versions of Windows).
SM_CYMAXIMIZED = 62
Win 95/98 only: Return the default height of a maximized window.
SM_CYMAXTRACK = 60
Win 95/98 only: Return the default maximum height the user is allowed to resize a window to.
SM_CYMENU = 15
Return the height of a single menu bar.
SM_CYMENUCHECK = 72
Win 95/98 only: Return the height of the default menu check-mark bitmap.
SM_CYMENUSIZE = 55
Win 95/98 only: Return the height of a menu bar button.
SM_CYMIN = 29
Return the minimum height of a window.
SM_CYMINIMIZED = 58
Win 95/98 only: Return the height of a normal minimized window.
SM_CYMINSPACING = 48
Win 95/98 only: Return the height of the grid cell rectangle used to position minimized windows.
SM_CYMINTRACK = 35
Win 95/98 only: Return the default minimum height the user is allowed to resize a window to.
SM_CYSCREEN = 1
Return the height of the screen.
SM_CYSIZE = 31
Win NT: Return the height of a title bar bitmap. Win 95/98: Return the height of a caption button.
SM_CYSIZEFRAME = 33
Win 95/98 only: Return the height of a thick window frame.
SM_CYSMCAPTION = 51
Win 95/98 only: Return the height of a small caption area.
SM_CYSMICON = 50
Win 95/98 only: Return the recommended height for small icons.
SM_CYSMSIZE = 53
Win 95/98 only: Return the height of a small caption button.
SM_CYVSCROLL = 20
Win 95/98 only: Return the height of an arrow bitmap on a vertical scrollbar.
SM_CYVTHUMB = 9
Return the height of a vertical scrollbar thumb.
SM_DBCSENABLED = 42
Return a non-zero value if the double-byte character set version of USER.EXE is installed, 0 if not.
SM_DEBUG = 22
Return a non-zero value if the debugging version of USER.EXE is installed, 0 if not.
SM_MENUDROPALIGNMENT = 40
Return a non-zero value if popup menus appear to the right, 0 if to the left.
SM_MIDEASTENABLED = 74
Return a non-zero value if the system is enabled to use Hebrew and Arabic languages, 0 if not.
SM_MOUSEPRESENT = 19
Return a non-zero value if a mouse is installed and present, 0 if not.
SM_NETWORK = 63
Set the &H1 bit of the return value if a network is installed. All other bits of the return value are reserved and undefined.
SM_PENWINDOWS = 41
Return a non-zero value if the Microsoft Windows for Pen computing extensions are installed, 0 if not.
SM_SECURE = 44
Return a non-zero value if security is present and active, 0 if not.
SM_SHOWSOUNDS = 70
Return a non-zero value if the application should show a visual cue for all sounds, 0 if not.
SM_SLOWMACHINE = 73
Return a non-zero value if the system has a slow, low-end processor, 0 if not.
SM_SWAPBUTTON = 23
Return a non-zero value if the left and right mouse buttons are swapped, 0 if not.

Example:

' Display the screen resolution (size) and some information about the
' configuration of windows.
Dim xres As Long, yres As Long  ' receive x and y resolutions of the display
Dim hasmouse As Long, numbuttons As Long  ' receive presense of mouse and number of buttons
Dim hasnetwork As Long  ' receives info on availability of network

' Display the screen resolution -- i.e., the width and height of the screen.
xres = GetSystemMetrics(SM_CXSCREEN)
yres = GetSystemMetrics(SM_CYSCREEN)
Debug.Print "The display is"; xres; "pixels wide and"; yres; "pixels high."

' Display the number of buttons on the mouse, if a mouse is present.
hasmouse = GetSystemMetrics(SM_MOUSEPRESENT)
numbuttons = GetSystemMetrics(SM_CMOUSEBUTTONS)
If hasmouse = 0 Then
  Debug.Print "No mouse is installed on the system."
Else
  Debug.Print "A mouse with"; numbuttons; "buttons is installed."
End If

' Display whether the system has a network connection installed.
hasnetwork = GetSystemMetrics(SM_NETWORK)
If (hasnetwork And &H1) = &H1 Then  ' check only the information bit
  Debug.Print "A network is configured to be used by Windows."
Else
  Debug.Print "No network is currently configured."
End If

See Also: SystemParametersInfo
Category: Accessibility

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getsystemmetrics.html