取得屏幕刷新率


using System;
using System.Runtime.InteropServices;


namespace ConsoleApplication
{

public sealed class EntryPoint
{
private EntryPoint(){}

[DllImport(
"Gdi32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern int GetDeviceCaps(IntPtr hDC,int nIndex);

/// <summary>
/// 获得屏幕刷新率
/// </summary>

public static int RefreshRate
{
get
{
IntPtr desktopDC 
= GetDC(GetDesktopWindow());
return GetDeviceCaps(desktopDC,116);
}

}


[DllImport(
"User32.dll")] 
public extern static IntPtr GetDesktopWindow();  

[DllImport(
"User32.dll")]
public static extern IntPtr GetDC(IntPtr hWnd);

static void Main()
{
Console.WriteLine(
"屏幕刷新率为: {0}Hz",RefreshRate);
Console.ReadLine();
}

}

}

原文地址:https://www.cnblogs.com/wy/p/209712.html