首頁  >  文章  >  类库下载  >  C# 程式碼調整螢幕分辨率

C# 程式碼調整螢幕分辨率

高洛峰
高洛峰原創
2016-10-13 16:27:282322瀏覽

使用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(); 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn