C# 如何检查Windows中是否启用了ClearType
在我的应用程序中,我想在运行时在一些textbox控件上设置ConsoleAs字体。由于Consolas是一种ClearType字体,并且只有在启用ClearType时才好看,所以我想检查ClearType是否启用 我可以检查ClearType是否已启用吗?请尝试使用,有关更多信息,请参阅此链接:C# 如何检查Windows中是否启用了ClearType,c#,.net,vb.net,C#,.net,Vb.net,在我的应用程序中,我想在运行时在一些textbox控件上设置ConsoleAs字体。由于Consolas是一种ClearType字体,并且只有在启用ClearType时才好看,所以我想检查ClearType是否启用 我可以检查ClearType是否已启用吗?请尝试使用,有关更多信息,请参阅此链接: 来自MSDN 和一个示例代码: Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParame
- 来自MSDN
Private Declare Function SystemParametersInfo Lib "user32" Alias
"SystemParametersInfoA" (ByVal uAction As Integer, _
ByVal uParam As Integer, ByRef lpvParam As Integer, _
ByVal fuWinIni As Integer) As Boolean
Private Const SPI_GETFONTSMOOTHINGTYPE As Integer = &H200A
Private Const FE_FONTSMOOTHINGCLEARTYPE As Integer = 2
Private Function IsClearTypeEnabled() As Boolean
Dim uiType As Integer = 0
Return SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, uiType, 0)
AndAlso uiType = FE_FONTSMOOTHINGCLEARTYPE
End Function
您可以使用System.Windows.Forms.SystemInformation的属性
public static bool IsClearTypeEnabled
{
get
{
try
{
return SystemInformation.FontSmoothingType == 2;
}
catch //NotSupportedException
{
return false;
}
}
}
除了@Claudio B给出的答案外,您可能还需要检查SystemInformation.IsFontSmoothingEnabled
属性,该属性检查字体平滑是否已启用。这是ClearType的独立设置:
public static bool IsClearTypeEnabled
{
get
{
return SystemInformation.IsFontSmoothingEnabled &&
SystemInformation.FontSmoothingType == 2;
}
,y