rt

解决方案 »

  1.   

    //: ScreenMode.cs - 设置显示模式
    //: Thu 2005.08.25namespace Skyiv
    {
      using System;
      using System.Windows.Forms;
      using System.Runtime.InteropServices;  class ScreenMode : Form
      {
        enum DMDO { DEFAULT = 0, D90 = 1, D180 = 2, D270 = 3 }    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        struct DEVMODE
        {
          public  const int DM_BITSPERPEL       = 0x040000;
          public  const int DM_PELSWIDTH        = 0x080000;
          public  const int DM_PELSHEIGHT       = 0x100000;
          public  const int DM_DISPLAYFREQUENCY = 0x400000;
          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;      public override string ToString()
          {
            return string.Format
            (
              "{0,4}×{1,-4} {2,2}Bits {3,3}Hz  {4}",
              dmPelsWidth,
              dmPelsHeight,
              dmBitsPerPel,
              dmDisplayFrequency,
              dmDeviceName
            );
          }
        }    [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern bool EnumDisplaySettings(int lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);    [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern int ChangeDisplaySettings([In] ref DEVMODE lpDevMode, int dwFlags);    ListBox lbxPels;    // 构造函数
        public ScreenMode()
        {
          Text                   = "显示属性";      lbxPels                = new ListBox();
          lbxPels.Parent         = this;
          lbxPels.Dock           = DockStyle.Fill;
          lbxPels.BeginUpdate();
          DEVMODE DevMode        = new DEVMODE();
          for (int i = 0; EnumDisplaySettings(0, i, ref DevMode); i++)
          {
            lbxPels.Items.Add(DevMode);
          }
          lbxPels.EndUpdate();      Button btnSet          = new Button();
          btnSet.Parent          = this;
          btnSet.Text            = "设置显示模式";
          btnSet.Dock            = DockStyle.Top;
          btnSet.Click          += new EventHandler(SetScrnMode);      Button btnGet          = new Button();
          btnGet.Parent          = this;
          btnGet.Text            = "当前显示属性";
          btnGet.Dock            = DockStyle.Top;
          btnGet.Click          += new EventHandler(GetScrnInfo);
        }    // 设置显示模式
        void SetScrnMode(object sender, EventArgs e)
        {
          if (lbxPels.SelectedItem != null)
          {
            DEVMODE DevMode = (DEVMODE)lbxPels.SelectedItem;
            ChangeDisplaySettings(ref DevMode, 0);
          }
        }    // 当前显示属性
        void GetScrnInfo(object sender, EventArgs e)
        {
          Screen scrn = Screen.PrimaryScreen;
          MessageBox.Show(
            string.Format
            (
              "主设备: {1}{0}设备名: {2}{0}边 界: {3}{0}工作区: {4}",
              Environment.NewLine,
              scrn.Primary,
              scrn.DeviceName,
              scrn.Bounds,
              scrn.WorkingArea
            ),
            "当前显示属性",
            MessageBoxButtons.OK,
            MessageBoxIcon.Information
          );
        }    // 程序入口
        [STAThread]
        static void Main()
        {
          Application.Run(new ScreenMode());
        }
      }
    }
      

  2.   


    因为这之前 LZ 给我发私信了:无主题
     qlzf11140820
     41 分钟前
     
    大侠 能不能请教个问题,c#中怎么修改DPI?或者 怎么直接Process打开显示属性->设置->高级中,直接打开高级,不打开显示属性,有没办法??我曾经用修改注册表的方式,该修改的项是改了,但不起作用,我想可能是字体要重启时安装什么的,哎,很郁闷,先谢了,这东东搞了两天时间了没解决,所以冒昧的问大侠有什么方法没啊。 wuyi8808
     5 分钟前
     
    你好,程序很长,这里贴不下,请在csdn C#版提问一下,我把程序贴给你。qlzf11140820
     3 分钟前
     
    好地 http://topic.csdn.net/u/20090909/16/79781ab8-eaa8-4e02-bdee-8e89d232e5f2.html
      

  3.   

    空军...你这个我给过类似的了.
    LZ要的是设置字体大小的那个DPI...
    说实话还真不知道怎么调.
      

  4.   

    vista下可以直接运行%windir%\system32\DpiScaling.exe打开那个对话框.
    可惜lz不是vista.
      

  5.   

    显示属性->设置->高级中 DPI设置
      

  6.   


    我没有别的意思 ~ 之前LZ 也给我发信了,
    我只找到了 获取DPI 的函数,想学习一下 ~
      

  7.   


    呵呵,我理解错 LZ 的意思了,暂时没有找到设置 DPI 的方法。
      

  8.   

    怎么没见 zgke ,不知道他有没有办法
      

  9.   

    奇怪了,我目前用的是 Windows Vista 操作系统,“显示属性->设置->高级”中,竟然没有“DPI设置”这一项,我记得在 Windows XP 中有这一项的。
      

  10.   

    这是 Windows Vista 的显示属性,没有找到 DPI 设置项:
    这是 Windows XP 的显示属性,有 DPI 设置项:
      

  11.   


    这是 Windows XP 的 DPI 设置窗口,不知如果不直接运行 DpiScaling.exe,如何进入:
      

  12.   


    我找到了,在 Windows Vista 下,“桌面->右键->个性化”,在左窗格中,单击“调整字体大小 (DPI)”。 
      

  13.   

    const string SubKey = @"Software\Fonts";RegistryKey rKey = Registry.CurrentConfig.OpenSubKey(SubKey);
                int dpi = (int)rKey.GetValue("LogPixels");            rKey.SetValue("LogPixels", 120);            rKey.Close();可惜不能写入,还没找到原因,你自己找找看为什么,不同的操作系统在不同的位置
      

  14.   

    RegistryKey rKey = Registry.CurrentConfig.OpenSubKey(SubKey, true); 
    不过修改后没什么效果,是不是要重启电脑
      

  15.   

    非常感谢wodegege10  原来我之前就把注册项该错了, 
      

  16.   

    我看了一下,上面还没有正确答案。qlzf11140820,有彻底解决方案了.需要改五个键,16个项,切换3种字体.下面是设置成 DPI=120 的注册表.Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI]
    "LogPixels"=dword:00000078[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
    "Courier 10,12,15 (8514a res)"="COURF.FON"
    "MS Serif 8,10,12,14,18,24 (8514a res)"="SERIFF.FON"
    "MS Sans Serif 8,10,12,14,18,24 (8514a res)"="SSERIFF.FON"
    "Small Fonts (8514a res)"="SMALLF.FON"[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\GRE_Initialize]
    "FIXEDFON.FON"="s8514fix.fon"
    "FONTS.FON"="s8514sys.fon"
    "OEMFONT.FON"="s8514oem.fon"[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0001\Software\Fonts]
    "FIXEDFON.FON"="s8514fix.fon"
    "FONTS.FON"="s8514sys.fon"
    "OEMFONT.FON"="s8514oem.fon"
    "LogPixels"=dword:00000078[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current\Software\Fonts]
    "FIXEDFON.FON"="s8514fix.fon"
    "FONTS.FON"="s8514sys.fon"
    "OEMFONT.FON"="s8514oem.fon"
    "LogPixels"=dword:00000078这是从一个老外的网站上得到的启示,我中间还把系统搞乱了。
    最后,把英文字体换成中文宋简体,并且改成了注册表格式。在我的WinXP计算机上,测试通过。96DPI的注册表,相同位置换一下就行了。C#代码不用写了吧,楼主分段复制进你原来的程序就行了。
      

  17.   

    测试方法:可以把上面的内容复制进一个文本文件,然后改名为dpi120.reg,双击,然后,选"是",注册完成,重启生效。