(原創) 如何得知目前顯示器的解析度? (.NET) (Windows Form)

C#

/* 
(C) OOMusou 2007 
http://oomusou.cnblogs.com

Filename    : ScreenResolution.cs
Compiler    : Visual Studio 2005 / C# 2.0
Description : Demo how to get resolution of monitor
Release     : 09/29/2007 1.0
*/

using System;
using System.Windows.Forms;
using System.Drawing;

class Client {
  
static void Main() {
    
int screenWidth = Screen.PrimaryScreen.Bounds.Width;
    
int screenHeight = Screen.PrimaryScreen.Bounds.Height;
    
    Console.WriteLine(
"Width:{0}, Height:{1}", screenWidth, screenHeight);
  }

}


執行結果

Width:1280, Height:768

這個方法只適合於Windows Form和Console,且必須reference System.Windows.Forms.dll和System.Drawing.dll,無法用於ASP.NET。

posted on 2007-09-29 15:30  真 OO无双  阅读(1505)  评论(1编辑  收藏  举报

导航