【发布时间】:2011-08-30 06:39:06
【问题描述】:
我需要确定用户的屏幕是否设置为普通 96 dpi(小尺寸)、120 dpi 大字体或其他。如何在 VB.NET(首选)或 C# 中做到这一点?
【问题讨论】:
-
原生方式(用 Delphi 编写,但仅使用原生 Windows API):
var dc: HDC; res: integer; begin dc := GetDC(0); if dc <> 0 then try res := GetDeviceCaps(dc, LOGPIXELSX); finally ReleaseDC(0, dc) end; -
正如 Andreas 建议的那样,您还可以调用 Windows API 函数
GetDC和GetDeviceCaps以获取此信息,但您必须使用 P/Invoke 从.NET 应用程序,这样做几乎没有什么好处,因为Graphics类已经很好地将其封装在托管代码中。 -
但无论如何,感谢paying your taxes!!
标签: .net windows vb.net winforms dpi