重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

C#代码调整屏幕分辨率-创新互联

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace 解决分辨率
{
    public partial class Form1 : Form
    {
        //保存当前屏幕分辨率
        int i = Screen.PrimaryScreen.Bounds.Width;
int j = Screen.PrimaryScreen.Bounds.Height;
        public Form1()
        {
            InitializeComponent();
        }
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct DEVMODE
        {
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
            public string dmDeviceName;
            public short dmSpecVersion;
            public short dmDriverVersion;
            public short dmSize;
            public short dmDriverExtra;
            public int dmFields;
            public short dmOrientation;
            public short dmPaperSize;
            public short dmPaperLength;
            public short dmPaperWidth;
            public short dmScale;
            public short dmCopies;
            public short dmDefaultSource;
            public short dmPrintQuality;
            public short dmColor;
            public short dmDuplex;
            public short dmYResolution;
            public short dmTTOption;
            public short dmCollate;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
            public string dmFormName;
            public short dmLogPixels;
            public int dmBitsPerPel;
            public int dmPelsWidth;
            public int dmPelsHeight;
            public int dmDisplayFlags;
            public int dmDisplayFrequency;
        }
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern int ChangeDisplaySettings([In] ref DEVMODE lpDevMode, int dwFlags);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern bool EnumDisplaySettings(string lpszDeviceName, Int32 iModeNum, ref DEVMODE lpDevMode);
        void ChangeRes()
        {

            DEVMODE DevM = new DEVMODE();
            DevM.dmSize = (short)Marshal.SizeOf(typeof(DEVMODE));
            bool mybool;
            mybool = EnumDisplaySettings(null, 0, ref DevM);
            DevM.dmPelsWidth = 1024;//宽
            DevM.dmPelsHeight = 768;//高
            DevM.dmDisplayFrequency = 60;//刷新频率
            DevM.dmBitsPerPel = 32;//颜色象素
            long result = ChangeDisplaySettings(ref DevM, 0);
        }
        void FuYuan()
        {
            DEVMODE DevM = new DEVMODE();
            DevM.dmSize = (short)Marshal.SizeOf(typeof(DEVMODE));
            bool mybool;
            mybool = EnumDisplaySettings(null, 0, ref DevM);
            DevM.dmPelsWidth = i;//恢复宽
            DevM.dmPelsHeight =j;//恢复高
            DevM.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();

        }

为顺平等地区用户提供了全套网页设计制作服务,及顺平网站建设行业解决方案。主营业务为成都网站建设、成都网站制作、顺平网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


网页名称:C#代码调整屏幕分辨率-创新互联
路径分享:http://cqcxhl.cn/article/ppood.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP