国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

如何獲取windows DPI設置值(Set Custom Text Size)

2019-11-11 04:28:06
字體:
來源:轉載
供稿:網友

首先添加引用:using System.Management;

 [DllImport("user32.dll")]        static extern IntPtr GetDC(IntPtr ptr);        [DllImport("user32.dll", EntryPoint = "ReleaseDC")]        public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);        [DllImport("gdi32.dll")]        public static extern IntPtr CreateDC(        string lpszDriver, // 驅動名稱        string lpszDevice, // 設備名稱        string lpszOutput, // 可設置為null        Int64 lpInitData // optional PRinter data        );        [DllImport("gdi32.dll")]        public static extern int GetDeviceCaps(        IntPtr hdc, // handle to DC        int nIndex // index of capability        );        [DllImport("user32.dll")]        internal static extern bool SetProcessDPIAware();        const int LOGPIXELSX = 88;        const int LOGPIXELSY = 90;
//在方法中添加如下代碼進行獲取
 SetProcessDPIAware(); //這句很重要            IntPtr screenDC = GetDC(IntPtr.Zero);            int dpi_x = GetDeviceCaps(screenDC, LOGPIXELSX);//96 是100%、120 是125%            int dpi_y = GetDeviceCaps(screenDC,LOGPIXELSY);            ReleaseDC(IntPtr.Zero, screenDC);


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 潼关县| 定陶县| 黔西| 定襄县| 新郑市| 隆德县| 苏州市| 通化市| 柞水县| 蒙山县| 永平县| 尤溪县| 砚山县| 商河县| 仙游县| 双江| 将乐县| 新疆| 肃北| 达日县| 岳西县| 江山市| 双城市| 安福县| 巢湖市| 铅山县| 建始县| 巴彦淖尔市| 海盐县| 华阴市| 乌恰县| 柘城县| 堆龙德庆县| 北安市| 新平| 谢通门县| 马山县| 龙州县| 酉阳| 连平县| 循化|