다음을 통해 공유


PerformanceCounterCategory.Delete(String) 메서드

정의

로컬 컴퓨터에서 범주와 관련 카운터를 제거합니다.

public:
 static void Delete(System::String ^ categoryName);
public static void Delete (string categoryName);
static member Delete : string -> unit
Public Shared Sub Delete (categoryName As String)

매개 변수

categoryName
String

삭제할 사용자 지정 성능 카운터 범주의 이름입니다.

예외

categoryName 매개 변수가 null인 경우

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

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

이 범주가 사용자 지정 범주가 아니므로 삭제될 수 없는 경우

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

예제

다음 코드 예제에서는 Delete 삭제 하는 PerformanceCounterCategory 메서드 및 PerformanceCounter 포함 된 개체입니다.

public static void Main(string[] args)
{
    string categoryName = "";

    // Copy the supplied argument into the local variable.
    try
    {
        categoryName = args[0];
    }
    catch (Exception ex)
    {
        Console.WriteLine("Missing argument identifying category to be deleted.");
    }

    // Delete the specified category.
    try
    {
        if (PerformanceCounterCategory.Exists(categoryName))
        {
            PerformanceCounterCategory.Delete(categoryName);
            Console.WriteLine("Category \"{0}\" deleted from this computer.", categoryName);
        }
        else
        {
            Console.WriteLine("Category name not found");
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine("Unable to delete " +
            "category \"{0}\" from this computer:" + "\n" + ex.Message, categoryName);
    }
}
Sub Main(ByVal args() As String)
    Dim categoryName As String = ""

    ' Copy the supplied argument into the local variable.
    Try
        categoryName = args(0)
    Catch ex As Exception
        Console.WriteLine("Missing argument identifying category to be deleted.")
    End Try

    ' Delete the specified category.
    Try
        If (PerformanceCounterCategory.Exists(categoryName)) Then
            PerformanceCounterCategory.Delete(categoryName)
            Console.WriteLine( _
                "Category ""{0}"" deleted from this computer.", categoryName)
        Else
            Console.WriteLine("Category name not found")
        End If

    Catch ex As Exception
        Console.WriteLine("Unable to delete " & _
            "category ""{0}"" from this computer:" & vbCrLf & _
            ex.Message, categoryName)
    End Try
End Sub

설명

시스템에서 사용자 지정 성능 카운터 범주만 삭제할 수 있습니다. 범주에서 카운터를 삭제할 수 없습니다. 이렇게 하려면 범주를 삭제하고 유지하려는 카운터를 사용하여 범주를 다시 만듭니다. 예외를 방지하려면 삭제를 시도하기 전에 범주가 있는지 확인합니다.

참고

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

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

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

적용 대상

추가 정보