PerformanceCounterCategory.CategoryName プロパティ

定義

このカテゴリを定義するパフォーマンス オブジェクト名を取得または設定します。Gets or sets the name of the performance object that defines this category.

public:
 property System::String ^ CategoryName { System::String ^ get(); void set(System::String ^ value); };
public string CategoryName { get; set; }
member this.CategoryName : string with get, set
Public Property CategoryName As String

プロパティ値

この PerformanceCounterCategory インスタンスを関連付けるパフォーマンス カウンター カテゴリまたはパフォーマンス オブジェクトの名前。The name of the performance counter category, or performance object, with which to associate this PerformanceCounterCategory instance.

例外

CategoryName が空の文字列 ("") です。The CategoryName is an empty string ("").

CategoryNamenull です。The CategoryName is null.

次のコード例では、PerformanceCounterCategory()を使用して PerformanceCounterCategory を作成します。The following code example creates a PerformanceCounterCategory with the PerformanceCounterCategory(). ユーザーに PerformanceCounterCategory とコンピューター名の入力を求めるプロンプトが表示されたら、入力した値の CategoryNameMachineName のプロパティを設定します。It prompts the user for the PerformanceCounterCategory and computer names, then sets the CategoryName and MachineName properties from the entered values. 次に、CategoryNameMachineName、および CategoryHelp プロパティの値が表示されます。 PerformanceCounterCategory にアクセスできない場合は、エラーメッセージが表示されます。It then displays the values of the CategoryName, MachineName, and CategoryHelp properties, or it displays an error message if the PerformanceCounterCategory cannot be accessed.

public static void Main(string[] args)
{
    string categoryName = "";
    string machineName = "";
    PerformanceCounterCategory pcc = new PerformanceCounterCategory();

    // Prompt for fields and set the corresponding properties.
    while (categoryName.Length==0)
    {
        Console.Write("Please enter a non-blank category name: ");
        categoryName = Console.ReadLine().Trim();
        if (categoryName.Length>0)
        {
            pcc.CategoryName = categoryName;
        }
    }
    while (machineName.Length==0)
    {
        Console.Write("Enter a non-blank computer name ['.' for local]: ");
        machineName = Console.ReadLine().Trim();
        if (machineName.Length>0)
        {
            pcc.MachineName = machineName;
        }
    }

    // Display the properties of the PerformanceCounterCategory object.
    try
    {
        Console.WriteLine("  Category:  {0}", pcc.CategoryName);
        Console.WriteLine("  Computer:  {0}", pcc.MachineName);
        Console.WriteLine("  Help text: {0}", pcc.CategoryHelp);
    }
    catch(Exception ex)
    {
        Console.WriteLine("Error getting the properties of the " +
            "PerformanceCounterCategory object:");
        Console.WriteLine(ex.Message);
    }
}
Sub Main(ByVal args() As String)
    Dim categoryName As String = ""
    Dim machineName As String = ""
    Dim pcc As New PerformanceCounterCategory

    ' Prompt for fields and set the corresponding properties.
    While categoryName.Length = 0
        Console.Write("Please enter a non-blank category name: ")
        categoryName = Console.ReadLine().Trim
        If categoryName.Length > 0 Then
            pcc.CategoryName = categoryName
        End If
    End While
    While machineName.Length = 0
        Console.Write( _
            "Enter a non-blank computer name ['.' for local]: ")
        machineName = Console.ReadLine().Trim
        If machineName.Length > 0 Then
            pcc.MachineName = machineName
        End If
    End While

    ' Display the properties of the PerformanceCounterCategory object.
    Try
        Console.WriteLine("  Category:  {0}", pcc.CategoryName)
        Console.WriteLine("  Computer:  {0}", pcc.MachineName)
        Console.WriteLine("  Help text: {0}", pcc.CategoryHelp)
    Catch ex As Exception
        Console.WriteLine("Error getting the properties of the " & _
            "PerformanceCounterCategory object:")
        Console.WriteLine(ex.Message)
    End Try
End Sub

セキュリティ

PerformanceCounterPermission
パフォーマンスカウンターカテゴリを読み取ります。for reading performance counter categories. Read (関連する列挙体)Associated enumeration: Read.

適用対象

こちらもご覧ください