OSFeature.IsPresent(SystemParameter) Yöntem

Tanım

İşletim sisteminin belirtilen özelliği veya ölçümü destekleyip desteklemediğini belirten bir değer alır.

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

Parametreler

enumVal
SystemParameter

SystemParameter Aranacak özelliği temsil eden.

Döndürülenler

Boolean

true özellik sistemde kullanılabiliyorsa; aksi takdirde , false.

Örnekler

Aşağıdaki kod örneği, yönteminin IsPresent sabit listesiyle SystemParameter nasıl kullanılacağını gösterir. Örnek, özelliği çağırmadan SystemInformation.CaretWidth önce işletim sisteminin ölçümü desteklenip desteklemediğini CaretWidth belirler.

#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

Açıklamalar

Genellikle, işletim sisteminin tarafından enumValuetanımlanan belirli özelliği veya ölçümü desteklenip desteklemediğini belirlemek için yöntemini kullanırsınızIsPresent. dosyasından IsPresentdöndürülen değere bağlı olarak, kodunuzda koşullu eylemler gerçekleştirebilirsiniz. Örneğin, bu yöntemi bir parametre değeri FlatMenu döndürerek trueçağırırsanız, uygulamanızda düz bir stilde sahip tarafından çizilmiş menüler oluşturabilirsiniz.

Belirli bir işletim sistemi sürümünde kullanılamayan bazı sistem özelliklerine veya ölçümlerine erişmek özel durumlara neden olabilir. Bu durumda, ölçümün desteklenip desteklenmediğini belirlemek için öncelikle ile IsPresentbirlikte karşılık gelen SystemParameter numaralandırma değerini kullanın. Örneğin, özellik değerini almadan önce ile CaretWidth öğesini çağırın.IsPresent SystemInformation.CaretWidth

Şunlara uygulanır

Ayrıca bkz.