C#中改变显示器的分辨率

转载 2006年05月18日 20:49:00
C#中改变显示器的分辨率
 

下面的代码实现修改显示器分辨率和刷新频率的功能:

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Runtime.InteropServices; namespace ScreenResolution { public class Form1 : System.Windows.Forms.Form { public enum DMDO { DEFAULT = 0, D90 = 1, D180 = 2, D270 = 3 } [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] struct DEVMODE { public const int DM_DISPLAYFREQUENCY = 0x400000; public const int DM_PELSWIDTH = 0x80000; public const int DM_PELSHEIGHT = 0x100000; private const int CCHDEVICENAME = 32; private const int CCHFORMNAME = 32; [MarshalAs(UnmanagedType.ByValTStr, SizeConst=CCHDEVICENAME)] public string dmDeviceName; public short dmSpecVersion; public short dmDriverVersion; public short dmSize; public short dmDriverExtra; public int dmFields; public int dmPositionX; public int dmPositionY; public DMDO dmDisplayOrientation; public int dmDisplayFixedOutput; public short dmColor; public short dmDuplex; public short dmYResolution; public short dmTTOption; public short dmCollate; [MarshalAs(UnmanagedType.ByValTStr, SizeConst=CCHFORMNAME)] public string dmFormName; public short dmLogPixels; public int dmBitsPerPel; public int dmPelsWidth; public int dmPelsHeight; public int dmDisplayFlags; public int dmDisplayFrequency; public int dmICMMethod; public int dmICMIntent; public int dmMediaType; public int dmDitherType; public int dmReserved1; public int dmReserved2; public int dmPanningWidth; public int dmPanningHeight; } [DllImport("user32.dll", CharSet=CharSet.Auto)] //static extern int ChangeDisplaySettings( DEVMODE lpDevMode, int dwFlags); static extern int ChangeDisplaySettings( [In] ref DEVMODE lpDevMode, int dwFlags); private System.ComponentModel.Container components = null; public Form1() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code private void InitializeComponent() { this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.Text = "改变屏幕分辨率的例子"; } #endregion static void Main() { Form1 r = new Form1(); r.ChangeRes(); Application.Run(new Form1()); } void ChangeRes() { Form1 t = new Form1(); long RetVal=0; DEVMODE dm = new DEVMODE(); dm.dmSize= (short)Marshal.SizeOf(typeof(DEVMODE)); dm.dmPelsWidth = 1024; dm.dmPelsHeight= 768; dm.dmDisplayFrequency=85; dm.dmFields = DEVMODE.DM_PELSWIDTH | DEVMODE.DM_PELSHEIGHT | DEVMODE.DM_DISPLAYFREQUENCY; RetVal = ChangeDisplaySettings(ref dm, 0); } } }



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=722220

相关文章推荐

C#改变显示器的分辨率

  • 2009-05-28 14:20
  • 34KB
  • 下载

linux手动更改显示器分辨率

 总结:w530是1080p的屏,但是hd4000显卡没有1600×900的分辨率可选,于是自己按照下面的方式,写了一个文件,双击运行-选择终端运行,就改变分辨率到1600×900: ...

获取当前显示器的分辨率

首先我们要获取当前使用的显卡sheb

C#获取显示器的分辨率

  • 2009-05-15 22:10
  • 46KB
  • 下载

改变显示器分辨率VB6.0

Ubuntu双显示器分辨率问题

1) $xrandr 得到显示器名称,我的为 VGA1,笔记本为LVDS1,大家以此类推,不一定都一样 2) $sudo xrandr --newmode "1440x900_60.00"  ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)