Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
GetSystemMetrics (user32)
.
C# Signature:
[DllImport("user32.dll")]
static extern int GetSystemMetrics(SystemMetric smIndex);
VB.NET Signature:
Public Declare Auto Function GetSystemMetrics Lib "user32.dll" (ByVal smIndex As Integer) As Integer
System metric or configuration setting to retrieve. This parameter can be one of the following values. Note that all SM_CX* values are widths and all SM_CY* values are heights. Also note that all settings designed to return Boolean data represent TRUE as any nonzero value, and FALSE as a zero value.
User-Defined Types:
The C# and VB Definition of the SystemMetric enum can be found here:
* System metrics may vary from display to display. Most values are returned in number of pixels, all others are flag or boolean values.
* GetSystemMetrics(SM_CMONITORS) counts only display monitors. This is different from EnumDisplayMonitors, which enumerates display monitors and also non-display pseudo-monitors.
The SM_ARRANGE setting specifies how the system arranges minimized windows, and consists of a starting position and a direction. The starting position can be one of the following values.
Value
Meaning
ARW_BOTTOMLEFT
Start at the lower-left corner of the screen (default position).
ARW_BOTTOMRIGHT
Start at the lower-right corner of the screen. Equivalent to ARW_STARTRIGHT.
ARW_HIDE
Hide minimized windows by moving them off the visible area of the screen.
ARW_TOPLEFT
Start at the upper-left corner of the screen. Equivalent to ARV_STARTTOP.
ARW_TOPRIGHT
Start at the upper-right corner of the screen. Equivalent to ARW_STARTTOP | SRW_STARTRIGHT.
The direction in which to arrange can be one of the following values.
Value
Meaning
ARW_DOWN
Arrange vertically, top to bottom.
ARW_LEFT
Arrange horizontally, left to right.
ARW_RIGHT
Arrange horizontally, right to left.
ARW_UP
Arrange vertically, bottom to top.
Tips & Tricks:
Use the Form.ClientSize method to get the size of the working area of the window, which is much easier than calculating the system
metrics yourself to get the same result (something that you could do if you had to, and had to do back in the day):
Sample Code C#:
The following example creates a new ListView control, and displays each member of the enumerator and it's return value. To use this example, paste it into the code (not the deigner code) file of a blank form. (ie, Form1.cs), if you have AIPCC installed you wont need to use the WindowsAPI class, instead it will be imported fron the AIP class library.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CodeCoreUI_Diagnostics
{
public partial class Form1:Form
{
public partial class WindowsAPI
{
// *** PASTE SYSTEMMETRIC ENUM HERE ***
[DllImport("user32.dll")]
public static extern int GetSystemMetrics(SystemMetric smIndex);
}
foreach (int i in Enum.GetValues(typeof(WindowsAPI.SystemMetric)))
{
x = Enum.GetName(typeof(WindowsAPI.SystemMetric),i);
u=WindowsAPI.GetSystemMetrics(( WindowsAPI.SystemMetric)i);
lvi = lvMain.Items.Add(x);
lvi.SubItems.Add(i.ToString());
lvi.SubItems.Add(u.ToString());
}
}
}
}
Alternative Managed API:
System.Windows.Forms.SystemInformation class
AIPCC.NET Windows API Library is available for free use (still in development)
The extensions are semi-managed via the GC and Exception Handling.
Site Resources:
Documentation tested on Microsoft Visual Studio 2005
Information Supplied or Quoted from Microsoft Developer News (MSDN) 2006 Feb.
Values to retrieve various system metrics
4/23/2018 9:00:56 PM - -72.45.243.234
Values to retrieve various system metrics
4/23/2018 9:00:56 PM - -72.45.243.234
Values to retrieve various system metrics
4/23/2018 9:00:56 PM - -72.45.243.234
The EnumDisplayMonitors API
6/15/2020 1:24:20 PM - -165.214.11.71
TODO - a short description
10/10/2012 6:23:12 AM - anonymous
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).