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

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

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

2019-11-11 06:29:59
字體:
來源:轉載
供稿:網友

首先添加引用: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);


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 犍为县| 紫金县| 洪泽县| 永新县| 邹城市| 临洮县| 凉城县| 灵丘县| 澜沧| 舒兰市| 静安区| 固安县| 松阳县| 调兵山市| 永和县| 澎湖县| 文昌市| 绥棱县| 隆林| 武汉市| 佛教| 开封县| 丰宁| 林芝县| 揭阳市| 中卫市| 彰武县| 十堰市| 涿鹿县| 合川市| 通海县| 五河县| 马尔康县| 左贡县| 武宁县| 和政县| 鄂伦春自治旗| 吉林市| 无为县| 广东省| 云浮市|