次の方法で共有


PerformanceCounterCategory.Exists メソッド (String)

カテゴリがローカル コンピュータに登録されているかどうかを判断します。

Overloads Public Shared Function Exists( _
   ByVal categoryName As String _) As Boolean
[C#]
public static bool Exists(stringcategoryName);
[C++]
public: static bool Exists(String* categoryName);
[JScript]
public static function Exists(
   categoryName : String) : Boolean;

パラメータ

  • categoryName
    検索するパフォーマンス カウンタ カテゴリの名前。

戻り値

true カテゴリが登録されている場合は 。それ以外の場合は false

例外

例外の種類 条件
ArgumentNullException categoryName パラメータが null 参照 (Visual Basic では Nothing) です。
ArgumentException categoryName パラメータが空の文字列 ("") です。
Win32Exception 基になるシステム API の呼び出しに失敗しました。

使用例

 
If Not PerformanceCounterCategory.Exists("Orders") Then        
    Dim milk As New CounterCreationData()
    milk.CounterName = "milk"
    milk.CounterType = PerformanceCounterType.NumberOfItems32
    
    Dim milkPerSecond As New CounterCreationData()
    milkPerSecond.CounterName = "milk orders/second"
    milkPerSecond.CounterType = PerformanceCounterType.RateOfCountsPerSecond32
    
    Dim ccds As New CounterCreationDataCollection()
    ccds.Add(milkPerSecond)
    ccds.Add(milk)
    
    PerformanceCounterCategory.Create("Orders", "Number of processed orders", ccds)    
End If

[C#] 
if(!PerformanceCounterCategory.Exists("Orders")) {          
    CounterCreationData milk = new CounterCreationData();
    milk.CounterName = "milk";
    milk.CounterType = PerformanceCounterType.NumberOfItems32;
    
    CounterCreationData milkPerSecond = new CounterCreationData();
    milkPerSecond.CounterName = "milk orders/second";
    milkPerSecond.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;
   
    CounterCreationDataCollection ccds = new CounterCreationDataCollection();
    ccds.Add(milkPerSecond);
    ccds.Add(milk);
    
    PerformanceCounterCategory.Create("Orders","Number of processed orders",ccds);           
}

[C++] 
if(!PerformanceCounterCategory::Exists(S"Orders")) {          
    CounterCreationData* milk = new CounterCreationData();
    milk->CounterName = S"milk";
    milk->CounterType = PerformanceCounterType::NumberOfItems32;

    CounterCreationData* milkPerSecond = new CounterCreationData();
    milkPerSecond->CounterName = S"milk orders/second";
    milkPerSecond->CounterType = PerformanceCounterType::RateOfCountsPerSecond32;

    CounterCreationDataCollection* ccds = new CounterCreationDataCollection();
    ccds->Add(milkPerSecond);
    ccds->Add(milk);

    PerformanceCounterCategory::Create(S"Orders",S"Number of processed orders",ccds);           
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

PerformanceCounterCategory クラス | PerformanceCounterCategory メンバ | System.Diagnostics 名前空間 | PerformanceCounterCategory.Exists オーバーロードの一覧 | CounterExists | InstanceExists