Share via


PerformanceCounterCategory.Create 메서드

정의

사용자 지정 성능 카운터 범주와 하나 이상의 카운터를 시스템에 등록합니다.

오버로드

Create(String, String, String, String)
사용되지 않음.
사용되지 않음.
사용되지 않음.

NumberOfItems32 형식의 단일 카운터를 포함하는 사용자 지정 성능 카운터 범주를 로컬 컴퓨터에 등록합니다.

Create(String, String, PerformanceCounterCategoryType, String, String)

NumberOfItems32 형식의 단일 카운터를 포함하는 사용자 지정 성능 카운터 범주를 로컬 컴퓨터에 등록합니다.

Create(String, String, CounterCreationDataCollection)
사용되지 않음.
사용되지 않음.
사용되지 않음.

지정한 카운터를 포함하는 사용자 지정 성능 카운터 범주를 로컬 컴퓨터에 등록합니다.

Create(String, String, PerformanceCounterCategoryType, CounterCreationDataCollection)

지정한 카운터를 포함하는 사용자 지정 성능 카운터 범주를 로컬 컴퓨터에 등록합니다.

Create(String, String, String, String)

Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs

주의

This method has been deprecated. Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead. http://go.microsoft.com/fwlink/?linkid=14202

주의

This method has been deprecated. Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead. https://go.microsoft.com/fwlink/?linkid=14202

주의

This overload of PerformanceCounterCategory.Create has been deprecated. Use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead.

NumberOfItems32 형식의 단일 카운터를 포함하는 사용자 지정 성능 카운터 범주를 로컬 컴퓨터에 등록합니다.

public:
 static System::Diagnostics::PerformanceCounterCategory ^ Create(System::String ^ categoryName, System::String ^ categoryHelp, System::String ^ counterName, System::String ^ counterHelp);
[System.Obsolete("This method has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, string counterName, string counterHelp);
[System.Obsolete("This method has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, string counterName, string counterHelp);
[System.Obsolete("This overload of PerformanceCounterCategory.Create has been deprecated. Use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead.")]
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, string counterName, string counterHelp);
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, string counterName, string counterHelp);
[<System.Obsolete("This method has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead.  http://go.microsoft.com/fwlink/?linkid=14202")>]
static member Create : string * string * string * string -> System.Diagnostics.PerformanceCounterCategory
[<System.Obsolete("This method has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead.  https://go.microsoft.com/fwlink/?linkid=14202")>]
static member Create : string * string * string * string -> System.Diagnostics.PerformanceCounterCategory
[<System.Obsolete("This overload of PerformanceCounterCategory.Create has been deprecated. Use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, string counterName, string counterHelp) instead.")>]
static member Create : string * string * string * string -> System.Diagnostics.PerformanceCounterCategory
static member Create : string * string * string * string -> System.Diagnostics.PerformanceCounterCategory
Public Shared Function Create (categoryName As String, categoryHelp As String, counterName As String, counterHelp As String) As PerformanceCounterCategory

매개 변수

categoryName
String

만들어서 시스템에 등록할 사용자 지정 성능 카운터 범주의 이름입니다.

categoryHelp
String

사용자 지정 범주에 대한 설명입니다.

counterName
String

새 범주의 일부로 만들 NumberOfItems32 형식의 새 카운터 이름입니다.

counterHelp
String

새 사용자 지정 범주와 관련된 카운터에 대한 설명입니다.

반환

새 시스템 범주 또는 성능 개체와 관련된 PerformanceCounterCategory입니다.

특성

예외

counterNamenull이거나 빈 문자열("")인 경우

또는

counterName이 지정한 카운터가 이미 있는 경우

또는

counterName에 잘못된 구문이 있는 경우. 백슬래시 문자("\")를 포함하거나 길이가 80자보다 클 수 있습니다.

범주가 이미 로컬 컴퓨터에 있는 경우

categoryName이(가) null인 경우

또는

counterHelp이(가) null인 경우

내부 시스템 API를 호출하지 못한 경우

관리자 권한 없이 실행되는 코드가 성능 카운터를 읽으려고 한 경우

예제

다음 코드 예제에서는 메서드를 PerformanceCounterCategory 사용하여 각각에 대한 도움말 텍스트가 있는 및 단일 PerformanceCounterCreate(String, String, String, String) 만듭니다.

public static void Main(string[] args)
{
    string categoryName = "";
    string counterName = "";
    string categoryHelp = "";
    string counterHelp = "";
    PerformanceCounterCategory pcc;

    // Copy the supplied arguments into the local variables.
    try
    {
        categoryName = args[0];
        counterName = args[1];
        categoryHelp = args[2];
        counterHelp = args[3];
    }
    catch(Exception ex)
    {
        // Ignore the exception from non-supplied arguments.
    }

    Console.WriteLine("Category name: \"{0}\"", categoryName);
    Console.WriteLine("Category help: \"{0}\"", categoryHelp);
    Console.WriteLine("Counter name:  \"{0}\"", counterName);
    Console.WriteLine("Counter help:  \"{0}\"", counterHelp);

    // Use the Create overload that creates a single counter.
    try
    {
        pcc = PerformanceCounterCategory.Create(categoryName, categoryHelp, counterName, counterHelp);
        Console.WriteLine("Category \"{0}\" created.", pcc.CategoryName);
    }
    catch(Exception ex)
    {
        Console.WriteLine("Unable to create the above category and counter:" + "\n" + ex.Message);
    }
}
Sub Main(ByVal args() As String)
    Dim categoryName As String = ""
    Dim counterName As String = ""
    Dim categoryHelp As String = ""
    Dim counterHelp As String = ""
    Dim pcc As PerformanceCounterCategory

    ' Copy the supplied arguments into the local variables.
    Try
        categoryName = args(0)
        counterName = args(1)
        categoryHelp = args(2)
        counterHelp = args(3)
    Catch ex As Exception
        ' Ignore the exception from non-supplied arguments.
    End Try

    Console.WriteLine("Category name: ""{0}""", categoryName)
    Console.WriteLine("Category help: ""{0}""", categoryHelp)
    Console.WriteLine("Counter name:  ""{0}""", counterName)
    Console.WriteLine("Counter help:  ""{0}""", counterHelp)

    ' Use the Create overload that creates a single counter.
    Try
        pcc = PerformanceCounterCategory.Create( _
            categoryName, categoryHelp, counterName, counterHelp)
        Console.WriteLine("Category ""{0}"" created.", pcc.CategoryName)

    Catch ex As Exception
        Console.WriteLine( _
            "Unable to create the above category and counter:" & _
            vbCrLf & ex.Message)
    End Try
End Sub

설명

참고

Windows Vista 이상, Windows XP Professional x64 Edition 또는 Windows Server 2003의 비대화형 로그온 세션에서 성능 카운터를 읽으려면 성능 모니터 사용자 그룹의 구성원이거나 관리 권한이 있어야 합니다.

Windows Vista 이상에서 성능 카운터에 액세스하기 위해 권한을 상승시킬 필요가 없도록 하려면 성능 모니터 사용자 그룹에 자신을 추가합니다.

Windows Vista 이상에서는 UAC(사용자 계정 컨트롤)가 사용자 권한을 결정합니다. 기본 제공 Administrators 그룹의 멤버인 경우 두 개의 런타임 액세스 토큰(표준 사용자 액세스 토큰 및 관리자 액세스 토큰)이 할당됩니다. 기본적으로 표준 사용자 역할이 지정됩니다. 성능 카운터에 액세스하는 코드를 실행하려면 먼저 표준 사용자에서 관리자로 권한을 상승시켜야 합니다. 애플리케이션 아이콘을 마우스 오른쪽 단추로 클릭하고 관리자로 실행하도록 지정하여 애플리케이션을 시작하면 이 작업을 수행할 수 있습니다.

추가 정보

적용 대상

Create(String, String, PerformanceCounterCategoryType, String, String)

Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs

NumberOfItems32 형식의 단일 카운터를 포함하는 사용자 지정 성능 카운터 범주를 로컬 컴퓨터에 등록합니다.

public:
 static System::Diagnostics::PerformanceCounterCategory ^ Create(System::String ^ categoryName, System::String ^ categoryHelp, System::Diagnostics::PerformanceCounterCategoryType categoryType, System::String ^ counterName, System::String ^ counterHelp);
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, System.Diagnostics.PerformanceCounterCategoryType categoryType, string counterName, string counterHelp);
static member Create : string * string * System.Diagnostics.PerformanceCounterCategoryType * string * string -> System.Diagnostics.PerformanceCounterCategory
Public Shared Function Create (categoryName As String, categoryHelp As String, categoryType As PerformanceCounterCategoryType, counterName As String, counterHelp As String) As PerformanceCounterCategory

매개 변수

categoryName
String

만들어서 시스템에 등록할 사용자 지정 성능 카운터 범주의 이름입니다.

categoryHelp
String

사용자 지정 범주에 대한 설명입니다.

categoryType
PerformanceCounterCategoryType

범주가 MultiInstance, SingleInstance 또는 Unknown인지를 지정하는 PerformanceCounterCategoryType 값 중 하나입니다.

counterName
String

새 범주의 일부로 만들 새 카운터의 이름입니다.

counterHelp
String

새 사용자 지정 범주와 관련된 카운터에 대한 설명입니다.

반환

새 시스템 범주 또는 성능 개체와 관련된 PerformanceCounterCategory입니다.

예외

counterNamenull이거나 빈 문자열("")인 경우

또는

counterName이 지정한 카운터가 이미 있는 경우

또는

counterName에 잘못된 구문이 있는 경우. 백슬래시 문자("\")를 포함하거나 길이가 80자보다 클 수 있습니다.

범주가 이미 로컬 컴퓨터에 있는 경우

categoryName이(가) null인 경우

또는

counterHelp이(가) null인 경우

내부 시스템 API를 호출하지 못한 경우

관리자 권한 없이 실행되는 코드가 성능 카운터를 읽으려고 한 경우

예제

다음 코드 예제에서는 사용 하는 메서드입니다 Create . 이 예제에서는 사용자 지정 단일 instance 성능 카운터 범주를 만드는 방법을 보여 줍니다.

Console.WriteLine("Creating Inventory custom counter");
if (!PerformanceCounterCategory.Exists("Inventory"))
    PerformanceCounterCategory.Create("Inventory",
        "Truck inventory",
        PerformanceCounterCategoryType.SingleInstance,
        "Trucks", "Number of trucks on hand");
Console.WriteLine("Creating Inventory custom counter")
If Not PerformanceCounterCategory.Exists("Inventory") Then
    PerformanceCounterCategory.Create("Inventory", "Truck inventory", PerformanceCounterCategoryType.SingleInstance, "Trucks", "Number of trucks on hand")
End If

설명

매개 변수는 categoryType 성능 카운터 범주가 단일 instance 또는 다중 instance 여부를 지정합니다. 기본적으로 범주는 단일 instance 만들어지고 다른 instance 추가될 때 다중 instance 됩니다. 범주는 애플리케이션 설정 되 고 인스턴스가 런타임에 추가 되 면 생성 됩니다. .NET Framework 버전 1.0 및 1.1에서는 성능 카운터 범주가 다중 instance 또는 단일 instance 인지 알 필요가 없습니다. .NET Framework 2.0 PerformanceCounterCategoryType 에서는 열거형을 사용하여 성능 카운터에 여러 인스턴스가 있을 수 있는지 여부를 나타냅니다.

.NET Framework 2.0과 함께 설치된 성능 카운터 범주는 별도의 공유 메모리를 사용하며 각 성능 카운터 범주에는 자체 메모리가 있습니다. 레지스트리 키 <HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\범주 이름>\성능에 FileMappingSize라는 DWORD를 만들어 별도의 공유 메모리 크기를 지정할 수 있습니다. FileMappingSize 값 범주의 공유 메모리 크기 설정 됩니다. 기본 크기는 10 진수 131072입니다. FileMappingSize 값 없는 경우는 fileMappingSize 특성에 대 한 값을 performanceCounters 합니다 Machine.config 파일에 지정 된 요소를 사용할 구성 파일을 처리에 대 한 추가 오버 헤드를 유발 합니다. 레지스트리에서 파일 매핑 크기를 설정 하 여 애플리케이션 시작에 대 한 성능 향상을 이룰 수 있습니다.

참고

애플리케이션을 설치 하는 동안, 애플리케이션의 실행 중이 아니라 새 성능 카운터 범주를 만들 수 있음을 것이 좋습니다. 이렇게 하면 운영 체제에서 등록된 성능 카운터 범주 목록을 새로 고칠 수 있습니다. 목록을 새로 고치지 않으면 범주를 사용하려는 시도가 실패합니다.

참고

Windows Vista 이상, Windows XP Professional x64 Edition 또는 Windows Server 2003의 비대화형 로그온 세션에서 성능 카운터를 읽으려면 성능 모니터 사용자 그룹의 구성원이거나 관리 권한이 있어야 합니다.

Windows Vista 이상에서 성능 카운터에 액세스하기 위해 권한을 상승시킬 필요가 없도록 하려면 성능 모니터 사용자 그룹에 자신을 추가합니다.

Windows Vista 이상에서는 UAC(사용자 계정 컨트롤)가 사용자 권한을 결정합니다. 기본 제공 Administrators 그룹의 멤버인 경우 두 개의 런타임 액세스 토큰(표준 사용자 액세스 토큰 및 관리자 액세스 토큰)이 할당됩니다. 기본적으로 표준 사용자 역할이 지정됩니다. 성능 카운터에 액세스하는 코드를 실행하려면 먼저 표준 사용자에서 관리자로 권한을 상승시켜야 합니다. 애플리케이션 아이콘을 마우스 오른쪽 단추로 클릭하고 관리자로 실행하도록 지정하여 애플리케이션을 시작하면 이 작업을 수행할 수 있습니다.

추가 정보

적용 대상

Create(String, String, CounterCreationDataCollection)

Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs

주의

This method has been deprecated. Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead. http://go.microsoft.com/fwlink/?linkid=14202

주의

This method has been deprecated. Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead. https://go.microsoft.com/fwlink/?linkid=14202

주의

This overload of PerformanceCounterCategory.Create has been deprecated. Use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead.

지정한 카운터를 포함하는 사용자 지정 성능 카운터 범주를 로컬 컴퓨터에 등록합니다.

public:
 static System::Diagnostics::PerformanceCounterCategory ^ Create(System::String ^ categoryName, System::String ^ categoryHelp, System::Diagnostics::CounterCreationDataCollection ^ counterData);
[System.Obsolete("This method has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, System.Diagnostics.CounterCreationDataCollection counterData);
[System.Obsolete("This method has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, System.Diagnostics.CounterCreationDataCollection counterData);
[System.Obsolete("This overload of PerformanceCounterCategory.Create has been deprecated. Use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead.")]
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, System.Diagnostics.CounterCreationDataCollection counterData);
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, System.Diagnostics.CounterCreationDataCollection counterData);
[<System.Obsolete("This method has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")>]
static member Create : string * string * System.Diagnostics.CounterCreationDataCollection -> System.Diagnostics.PerformanceCounterCategory
[<System.Obsolete("This method has been deprecated.  Please use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead.  https://go.microsoft.com/fwlink/?linkid=14202")>]
static member Create : string * string * System.Diagnostics.CounterCreationDataCollection -> System.Diagnostics.PerformanceCounterCategory
[<System.Obsolete("This overload of PerformanceCounterCategory.Create has been deprecated. Use System.Diagnostics.PerformanceCounterCategory.Create(string categoryName, string categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) instead.")>]
static member Create : string * string * System.Diagnostics.CounterCreationDataCollection -> System.Diagnostics.PerformanceCounterCategory
static member Create : string * string * System.Diagnostics.CounterCreationDataCollection -> System.Diagnostics.PerformanceCounterCategory
Public Shared Function Create (categoryName As String, categoryHelp As String, counterData As CounterCreationDataCollection) As PerformanceCounterCategory

매개 변수

categoryName
String

만들어서 시스템에 등록할 사용자 지정 성능 카운터 범주의 이름입니다.

categoryHelp
String

사용자 지정 범주에 대한 설명입니다.

counterData
CounterCreationDataCollection

새 범주의 일부로 만들 카운터를 지정하는 CounterCreationDataCollection입니다.

반환

새 사용자 지정 범주 또는 성능 개체와 관련된 PerformanceCounterCategory입니다.

특성

예외

counterData 컬렉션에 지정된 카운터 이름이 null이거나 빈 문자열("")인 경우

또는

지정된 카운터가 counterData 컬렉션에 이미 있는 경우

또는

counterName 매개 변수 구문이 잘못된 경우. 백슬래시 문자("\")를 포함하거나 길이가 80자보다 클 수 있습니다.

categoryName 매개 변수가 null인 경우

범주가 이미 로컬 컴퓨터에 있는 경우

또는

counterData 컬렉션의 레이아웃이 기본 카운터에 맞지 않는 경우. AverageCount64, AverageTimer32, CounterMultiTimer, CounterMultiTimerInverse, CounterMultiTimer100Ns, CounterMultiTimer100NsInverse, RawFraction, SampleFraction 또는 SampleCounter 형식의 카운터 바로 다음에는 기본 카운터 형식(AverageBase, MultiBase, RawBase 또는 SampleBase)중 하나가 와야 합니다.

내부 시스템 API를 호출하지 못한 경우

관리자 권한 없이 실행되는 코드가 성능 카운터를 읽으려고 한 경우

예제

다음 코드 예제에서는 "orders"라는 개체가 PerformanceCounterCategory 있는지 여부를 결정합니다. 그렇지 않은 경우 두 개의 성능 카운터가 포함된 개체를 CounterCreationDataCollection 사용하여 개체를 만듭니다PerformanceCounterCategory.

if (  !PerformanceCounterCategory::Exists( "Orders" ) )
{
   CounterCreationData^ milk = gcnew CounterCreationData;
   milk->CounterName = "milk";
   milk->CounterType = PerformanceCounterType::NumberOfItems32;

   CounterCreationData^ milkPerSecond = gcnew CounterCreationData;
   milkPerSecond->CounterName = "milk orders/second";
   milkPerSecond->CounterType = PerformanceCounterType::RateOfCountsPerSecond32;

   CounterCreationDataCollection^ ccds = gcnew CounterCreationDataCollection;
   ccds->Add( milkPerSecond );
   ccds->Add( milk );
   PerformanceCounterCategory::Create( "Orders", "Number of processed orders", ccds );
}
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",
        PerformanceCounterCategoryType.SingleInstance, ccds);
}
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", _
           PerformanceCounterCategoryType.SingleInstance, ccds)
End If

설명

참고

Windows Vista 이상, Windows XP Professional x64 Edition 또는 Windows Server 2003의 비대화형 로그온 세션에서 성능 카운터를 읽으려면 성능 모니터 사용자 그룹의 구성원이거나 관리 권한이 있어야 합니다.

Windows Vista 이상에서 성능 카운터에 액세스하기 위해 권한을 상승시킬 필요가 없도록 성능 모니터 사용자 그룹에 자신을 추가합니다.

Windows Vista 이상에서는 UAC(사용자 계정 컨트롤)가 사용자 권한을 결정합니다. 기본 제공 Administrators 그룹의 멤버인 경우 두 개의 런타임 액세스 토큰(표준 사용자 액세스 토큰 및 관리자 액세스 토큰)이 할당됩니다. 기본적으로 표준 사용자 역할이 지정됩니다. 성능 카운터에 액세스하는 코드를 실행하려면 먼저 표준 사용자에서 관리자로 권한을 상승시켜야 합니다. 애플리케이션 아이콘을 마우스 오른쪽 단추로 클릭하고 관리자로 실행하도록 지정하여 애플리케이션을 시작하면 이 작업을 수행할 수 있습니다.

추가 정보

적용 대상

Create(String, String, PerformanceCounterCategoryType, CounterCreationDataCollection)

Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs

지정한 카운터를 포함하는 사용자 지정 성능 카운터 범주를 로컬 컴퓨터에 등록합니다.

public:
 static System::Diagnostics::PerformanceCounterCategory ^ Create(System::String ^ categoryName, System::String ^ categoryHelp, System::Diagnostics::PerformanceCounterCategoryType categoryType, System::Diagnostics::CounterCreationDataCollection ^ counterData);
public static System.Diagnostics.PerformanceCounterCategory Create (string categoryName, string categoryHelp, System.Diagnostics.PerformanceCounterCategoryType categoryType, System.Diagnostics.CounterCreationDataCollection counterData);
static member Create : string * string * System.Diagnostics.PerformanceCounterCategoryType * System.Diagnostics.CounterCreationDataCollection -> System.Diagnostics.PerformanceCounterCategory
Public Shared Function Create (categoryName As String, categoryHelp As String, categoryType As PerformanceCounterCategoryType, counterData As CounterCreationDataCollection) As PerformanceCounterCategory

매개 변수

categoryName
String

만들어서 시스템에 등록할 사용자 지정 성능 카운터 범주의 이름입니다.

categoryHelp
String

사용자 지정 범주에 대한 설명입니다.

categoryType
PerformanceCounterCategoryType

PerformanceCounterCategoryType 값 중 하나입니다.

counterData
CounterCreationDataCollection

새 범주의 일부로 만들 카운터를 지정하는 CounterCreationDataCollection입니다.

반환

새 사용자 지정 범주 또는 성능 개체와 관련된 PerformanceCounterCategory입니다.

예외

counterData 컬렉션에 지정된 카운터 이름이 null이거나 빈 문자열("")인 경우

또는

지정된 카운터가 counterData 컬렉션에 이미 있는 경우

또는

counterName에 잘못된 구문이 있는 경우. 백슬래시 문자("\")를 포함하거나 길이가 80자를 초과할 수 있습니다.

categoryNamenull입니다.

또는

counterData이(가) null인 경우

categoryType 값이 MultiInstance, SingleInstance 또는 Unknown 값의 범위를 벗어난 경우

범주가 이미 로컬 컴퓨터에 있는 경우

또는

counterData 컬렉션의 레이아웃이 기본 카운터에 맞지 않는 경우. AverageCount64, AverageTimer32, CounterMultiTimer, CounterMultiTimerInverse, CounterMultiTimer100Ns, CounterMultiTimer100NsInverse, RawFraction, SampleFraction 또는 SampleCounter 형식의 카운터 바로 다음에는 기본 카운터 형식(AverageBase, MultiBase, RawBase 또는 SampleBase)중 하나가 와야 합니다.

내부 시스템 API를 호출하지 못한 경우

관리자 권한 없이 실행되는 코드가 성능 카운터를 읽으려고 한 경우

예제

다음 코드 예제에서는 사용 된 메서드입니다 Create . 이 예제에서는 초당 주문 수에 대한 사용자 지정 다중 instance 성능 카운터 범주를 만드는 방법을 보여 줍니다.

CounterCreationData data1 = new CounterCreationData("Trucks",
    "Number of orders", PerformanceCounterType.NumberOfItems32);
CounterCreationData data2 = new CounterCreationData("Rate of sales",
    "Orders/second", PerformanceCounterType.RateOfCountsPerSecond32);
CounterCreationDataCollection ccds = new CounterCreationDataCollection();
ccds.Add(data1);
ccds.Add(data2);
Console.WriteLine("Creating Orders custom counter.");
if (!PerformanceCounterCategory.Exists("Orders"))
    PerformanceCounterCategory.Create("Orders",
        "Processed orders",
        PerformanceCounterCategoryType.MultiInstance,
        ccds);
Dim data1 As New CounterCreationData("Trucks", "Number of orders", PerformanceCounterType.NumberOfItems32)
Dim data2 As New CounterCreationData("Rate of sales", "Orders/second", PerformanceCounterType.RateOfCountsPerSecond32)
Dim ccds As New CounterCreationDataCollection()
ccds.Add(data1)
ccds.Add(data2)
Console.WriteLine("Creating Orders custom counter.")
If Not PerformanceCounterCategory.Exists("Orders") Then
    PerformanceCounterCategory.Create("Orders", "Processed orders", PerformanceCounterCategoryType.MultiInstance, ccds)
End If

설명

매개 변수는 categoryType 성능 카운터 범주가 단일 instance 또는 다중 instance 여부를 지정합니다. 기본적으로 범주는 만들 때 단일 instance 다른 instance 추가될 때 다중 instance 됩니다. 범주는 애플리케이션 설정 되 고 인스턴스가 런타임에 추가 되 면 생성 됩니다. .NET Framework 버전 1.0 및 1.1에서는 성능 카운터 범주가 다중 instance 또는 단일 instance 인지 알 필요가 없습니다. .NET Framework 2.0 PerformanceCounterCategoryType 에서 열거형은 성능 카운터에 여러 인스턴스가 있을 수 있는지 여부를 나타내는 데 사용됩니다.

.NET Framework 2.0과 함께 설치된 성능 카운터 범주는 별도의 공유 메모리를 사용하며 각 성능 카운터 범주에는 자체 메모리가 있습니다. 레지스트리 키 <HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\category name>\Performance에 FileMappingSize라는 DWORD를 만들어 별도의 공유 메모리 크기를 지정할 수 있습니다. FileMappingSize 값 범주의 공유 메모리 크기 설정 됩니다. 기본 크기는 10 진수 131072입니다. FileMappingSize 값 없는 경우는 fileMappingSize 특성에 대 한 값을 performanceCounters 합니다 Machine.config 파일에 지정 된 요소를 사용할 구성 파일을 처리에 대 한 추가 오버 헤드를 유발 합니다. 레지스트리에서 파일 매핑 크기를 설정 하 여 애플리케이션 시작에 대 한 성능 향상을 이룰 수 있습니다.

참고

애플리케이션을 설치 하는 동안, 애플리케이션의 실행 중이 아니라 새 성능 카운터 범주를 만들 수 있음을 것이 좋습니다. 이렇게 하면 운영 체제가 등록된 성능 카운터 범주 목록을 새로 고칠 수 있습니다. 목록을 새로 고치지 않은 경우 범주를 사용하려고 하면 실패합니다.

참고

Windows Vista 이상, Windows XP Professional x64 Edition 또는 Windows Server 2003의 비대화형 로그온 세션에서 성능 카운터를 읽으려면 성능 모니터 사용자 그룹의 구성원이거나 관리 권한이 있어야 합니다.

Windows Vista 이상에서 성능 카운터에 액세스하기 위해 권한을 상승시킬 필요가 없도록 성능 모니터 사용자 그룹에 자신을 추가합니다.

Windows Vista 이상에서는 UAC(사용자 계정 컨트롤)가 사용자 권한을 결정합니다. 기본 제공 Administrators 그룹의 멤버인 경우 두 개의 런타임 액세스 토큰(표준 사용자 액세스 토큰 및 관리자 액세스 토큰)이 할당됩니다. 기본적으로 표준 사용자 역할이 지정됩니다. 성능 카운터에 액세스하는 코드를 실행하려면 먼저 표준 사용자에서 관리자로 권한을 상승시켜야 합니다. 애플리케이션 아이콘을 마우스 오른쪽 단추로 클릭하고 관리자로 실행하도록 지정하여 애플리케이션을 시작하면 이 작업을 수행할 수 있습니다.

추가 정보

적용 대상