The GetSystemMetrics API function returns values that give dimensions used by the system such as the default size of icons and the thickness of a resizable window's borders.
The following code shows how the program declares the GetSystemMetrics API function. (Note that the program includes the System.Runtime.InteropServices namespace so it can use DllImport.)
[DllImport("user32.dll")]
static extern int GetSystemMetrics(SystemMetric smIndex);
The following SystemMetric enumeration defines the parameters that you can pass to the GetSystemMetrics function.
The following AddValue method displays a metric's name and value in the lvwMetrics ListView control.
// Add a value to the ListView.
private void AddValue(SystemMetric metric)
{
ListViewItem item = lvwMetrics.Items.Add(metric.ToString());
item.SubItems.Add(GetSystemMetrics(metric).ToString());
}
Download the example and look at the code to see all 89 of the metrics.
Comments