zoukankan
html css js c++ java
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 );
}
Windows Form Designer generated code
#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
);
}
}
}
查看全文
相关阅读:
node.js 安装后怎么打开 node.js 命令框
thinkPHP5 where多条件查询
网站title中的图标
第一次写博客
Solution to copy paste not working in Remote Desktop
The operation could not be completed. (Microsoft.Dynamics.BusinessConnectorNet)
The package failed to load due to error 0xC0011008
VS2013常用快捷键
微软Dynamics AX的三层架构
怎样在TFS(Team Foundation Server)中链接团队项目
原文地址:https://www.cnblogs.com/wy/p/209573.html
最新文章
UVA 1078 dij模板 +建图难
自用新工程模板
UVA 11478 bf+差分约束系统+二分逼近
UVA11090 二分逼近+bf
2016"百度之星"
2016年团体程序设计天梯赛-模拟赛
2016百度之星资格赛
Hyperv宿主机无法链接(命令增加dns)
MOTO RFS 4000 配置
爬取湖北历年地震数据
热门文章
代理池爬取mzitu
通过代理爬mzitu
爬取xici代理
用my_fake_useragent生成headers
福利爬mzitu
爬取猫眼top100
mac os 环境变量
我的第一个小程序
注册的网页以及验证码的js代码
node.js 怎么新建一个站点端口
Copyright © 2011-2022 走看看