RegistryPermission.GetPathList(RegistryPermissionAccess) 메서드

정의

지정된 RegistryPermissionAccess를 갖는 모든 레지스트리 변수에 대한 경로를 가져옵니다.

public:
 System::String ^ GetPathList(System::Security::Permissions::RegistryPermissionAccess access);
public string GetPathList (System.Security.Permissions.RegistryPermissionAccess access);
member this.GetPathList : System.Security.Permissions.RegistryPermissionAccess -> string
Public Function GetPathList (access As RegistryPermissionAccess) As String

매개 변수

access
RegistryPermissionAccess

단일 유형의 레지스트리 변수 액세스를 나타내는 RegistryPermissionAccess 값 중 하나입니다.

반환

String

지정된 RegistryPermissionAccess를 갖는 레지스트리 변수 목록(세미콜론으로 구분)입니다.

예외

access는 유효한 RegistryPermissionAccess 값이 아닙니다.

또는 access 가 둘 이상의 레지스트리 변수 액세스 유형을 나타내는 AllAccess이거나 모든 레지스트리 변수 액세스 유형을 나타내지는 않는 NoAccess입니다.

예제

다음 코드 예제에서는 메서드의 사용을 보여 있습니다 GetPathList .

// AddPathList adds access for the specified registry variables to the existing state of the permission.
// SetPathList sets new access for the specified registry variable names to the existing state of the permission.
// GetPathList gets paths for all registry variables with the specified RegistryPermissionAccess.
private static bool SetGetPathListDemo()
{
    try
    {
        Console.WriteLine("********************************************************\n");
        RegistryPermission readPerm1;
        Console.WriteLine("Creating RegistryPermission with AllAccess rights for 'HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0'");
        readPerm1 = new RegistryPermission(RegistryPermissionAccess.AllAccess, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
        Console.WriteLine("Adding 'HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION' to the write access list, "
            + "and \n 'HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\FloatingPointProcessor\\0' "
            + "to the read access list.");
        readPerm1.AddPathList(RegistryPermissionAccess.Write, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION");
        readPerm1.AddPathList(RegistryPermissionAccess.Read,
            "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\FloatingPointProcessor\\0");
        Console.WriteLine("Read access list before SetPathList = " +
            readPerm1.GetPathList(RegistryPermissionAccess.Read));
        Console.WriteLine("Setting read access rights to \n'HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0'");
        readPerm1.SetPathList(RegistryPermissionAccess.Read,
            "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
        Console.WriteLine("Read access list after SetPathList = \n" +
            readPerm1.GetPathList(RegistryPermissionAccess.Read));
        Console.WriteLine("Write access = \n" +
            readPerm1.GetPathList(RegistryPermissionAccess.Write));
        Console.WriteLine("Write access Registry variables = \n" +
            readPerm1.GetPathList(RegistryPermissionAccess.AllAccess));
    }
    catch (ArgumentException e)
    {
        // RegistryPermissionAccess.AllAccess can not be used as a parameter for GetPathList.
        Console.WriteLine("An ArgumentException occurred as a result of using AllAccess. "
            + "AllAccess cannot be used as a parameter in GetPathList because it represents more than one "
            + "type of registry variable access : \n" + e);
    }

    return true;
}
' AddPathList adds access for the specified registry variables to the existing state of the permission.
' SetPathList sets new access for the specified registry variable names to the existing state of the permission.
' GetPathList gets paths for all registry variables with the specified RegistryPermissionAccess.
Private Shared Function SetGetPathListDemo() As Boolean
    Try
        Console.WriteLine("********************************************************" + vbLf)
        Dim readPerm1 As RegistryPermission
        Console.WriteLine("Creating RegistryPermission with AllAccess rights for 'HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0'")
        readPerm1 = New RegistryPermission(RegistryPermissionAccess.AllAccess, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0")
        Console.WriteLine("Adding 'HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION' to the write access list, " + "and " + vbLf + " 'HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\FloatingPointProcessor\0' " + "to the read access list.")
        readPerm1.AddPathList(RegistryPermissionAccess.Write, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION")
        readPerm1.AddPathList(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\FloatingPointProcessor\0")
        Console.WriteLine("Read access list before SetPathList = " + readPerm1.GetPathList(RegistryPermissionAccess.Read))
        Console.WriteLine("Setting read access rights to " + vbLf + "'HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0'")
        readPerm1.SetPathList(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0")
        Console.WriteLine("Read access list after SetPathList = " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.Read))
        Console.WriteLine("Write access = " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.Write))
        Console.WriteLine("Write access Registry variables = " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.AllAccess))
    Catch e As ArgumentException
        ' RegistryPermissionAccess.AllAccess can not be used as a parameter for GetPathList.
        Console.WriteLine("An ArgumentException occurred as a result of using AllAccess. " + _
        "AllAccess cannot be used as a parameter in GetPathList because it represents more than one " + _
        "type of registry variable access : " + vbLf + e.Message)
    End Try

    Return True

End Function 'SetGetPathListDemo

설명

이 메서드를 사용하여 현재 사용 권한의 상태를 가져옵니다. 각 액세스 유형에 대해 이 메서드를 별도로 호출해야 합니다.

참고

access 매개 변수는 레지스트리 변수 액세스의 RegistryPermissionAccess단일 형식을 나타내는 값으로 제한됩니다. 이러한 값은 Read, WriteCreate. 포함 NoAccess 할 수 access 있는 값 및 AllAccess단일 유형의 레지스트리 변수 액세스를 나타내지 않는 값입니다.

적용 대상