使用System;
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data;
使用System.Drawing;
使用System.Linq;
using System.Runtime.InteropServices;
命名空間解決解析
{
publicpartial class Form1 : Form
{
Width;
int j = Screen. PrimaryScreen. Bounds.Height;
public Form1()
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DEV MODE
32)]
公有字串dmDeviceName;
公共短dmSize;
公共短dmDriver額外;
公用短dmPaperSize;
公用短dmPaperLength;
公共短dmPaperWidth;
公共短dmScale;
公共短dmCopies;
公共短dmDefaultSource;
公共短dmPrintQuality;
公共短dm顏色;
公共短dmDuplex;
公共短dmYResolution;
公共短dmTTOption;
公共短dmCollat CyValTStr, SizeConst = 32)]
public string dmFormName public int dmBitsPerPel;
public int dmPelsWidth ;
public int dmDisplayFlags;
public int dmDisplayFrequency;
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
Flaic extern int ChangeDis Flaic extern int ChangeDis playpp. [DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern bool EnumDisplaySettings(string lpszDeviceName, Int32 iModeNum, ref DEVMODE c
DEVMODE DevM = new;
DevM.dmSize = (short)Marshal.SizeOftype( DEVMODE) );
bool mybool;
DevM.dmPelsWidth = 1024;//寬
DevM.dmPelsHeight = 768;//高
DevM.dmBitsPerPel = 32;//顏色像素
long result = ChangeDisplaySettings(ref DevM Dev, 0);
}
void FuYuan()
{ DevM.dmSize = (short)Marshal.SizeOf(typeof(DEVMODE));
, 0, ref DevM);
DevM.dmPelsWidth = i;//回復寬度
dmDisplayFrequency = 60;//刷新頻率
DevM.dmBitsPerPel = 32;//色像素
long result = ChangeDisplaySettings(ref DevM, 0);
}
private void Form1_Load(object sender, EventArgs e)
{
ChangeRes();
}
private void button1_Click(object sender, EventArgs e)
{
FuYuan();
this.Close();