OSFeature.IsPresent(SystemParameter) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Načte hodnotu označující, jestli operační systém podporuje zadanou funkci nebo metriku.
public:
static bool IsPresent(System::Windows::Forms::SystemParameter enumVal);
public static bool IsPresent(System.Windows.Forms.SystemParameter enumVal);
static member IsPresent : System.Windows.Forms.SystemParameter -> bool
Public Shared Function IsPresent (enumVal As SystemParameter) As Boolean
Parametry
- enumVal
- SystemParameter
Představuje SystemParameter funkci, kterou chcete vyhledat.
Návraty
trueje-li tato funkce k dispozici v systému; v opačném případě . false
Příklady
Následující příklad kódu ukazuje, jak použít metodu IsPresent s výčtem SystemParameter . Příklad určuje, jestli operační systém podporuje metriku CaretWidth před voláním SystemInformation.CaretWidth vlastnosti.
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms
// Gets the caret width based upon the operating system or default value.
int GetCaretWidth()
{
// Check to see if the operating system supports the caret width metric.
if ( OSFeature::Feature->IsPresent( SystemParameter::CaretWidthMetric ) )
{
// If the operating system supports this metric,
// return the value for the caret width metric.
return SystemInformation::CaretWidth;
}
else
1;
// If the operating system does not support this metric,
// return a custom default value for the caret width.
}
// Gets the caret width based upon the operating system or default value.
private int GetCaretWidth ()
{
// Check to see if the operating system supports the caret width metric.
if (OSFeature.IsPresent(SystemParameter.CaretWidthMetric))
{
// If the operating system supports this metric,
// return the value for the caret width metric.
return SystemInformation.CaretWidth;
} else
{
// If the operating system does not support this metric,
// return a custom default value for the caret width.
return 1;
}
}
' Gets the caret width based upon the operating system or default value.
Private Function GetCaretWidth() As Integer
' Check to see if the operating system supports the caret width metric.
If OSFeature.IsPresent(SystemParameter.CaretWidthMetric) Then
' If the operating system supports this metric,
' return the value for the caret width metric.
Return SystemInformation.CaretWidth
Else
' If the operating system does not support this metric,
' return a custom default value for the caret width.
Return 1
End If
End Function
Poznámky
Obvykle používáte metodu IsPresent k určení, zda operační systém podporuje konkrétní funkci nebo metriku identifikovanou enumValue. Na základě hodnoty vrácené z IsPresentkódu byste v kódu provedli podmíněné akce. Pokud například voláte tuto metodu s hodnotou parametru FlatMenu vrácení true, můžete v aplikaci vytvořit nabídky nakreslené vlastníkem v plochém stylu.
Přístup k některým systémovým funkcím nebo metrikám může vyvolat výjimky, pokud nejsou dostupné v konkrétní verzi operačního systému. V tomto případě nejprve použijte odpovídající SystemParameter hodnotu výčtu spolu s IsPresent, určit, zda je metrika podporována. Například volání IsPresent s CaretWidth před získáním SystemInformation.CaretWidth hodnoty vlastnosti.