静观其变

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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();
}

}

}

posted on 2005-08-08 09:48  wangyue  阅读(1317)  评论(0编辑  收藏  举报