RegistryPermission.GetPathList(RegistryPermissionAccess) Método

Definición

Obtiene las rutas de acceso para todas las variables del Registro con el RegistryPermissionAccess especificado.

C#
public string GetPathList(System.Security.Permissions.RegistryPermissionAccess access);

Parámetros

access
RegistryPermissionAccess

Uno de los valores de RegistryPermissionAccess que representa un tipo único de acceso a variables del Registro.

Devoluciones

Lista de las variables del Registro (separadas por punto y coma) con el RegistryPermissionAccess especificado.

Excepciones

access no es un valor válido de RegistryPermissionAccess.

o bien

access es AllAccess, que representa más de un tipo de acceso a variables del Registro o NoAccess, que no representa ningún tipo de acceso a variable del Registro.

Ejemplos

En el ejemplo de código siguiente se muestra el uso del GetPathList método .

C#
// 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;
}

Comentarios

Use este método para obtener el estado del permiso actual. Debe llamar a este método por separado para cada tipo de acceso.

Nota

El access parámetro se limita a los valores de RegistryPermissionAccess, que representan tipos únicos de acceso a variables del Registro. Esos valores son Read, Writey Create. Los valores aceptables para access no incluir NoAccess y AllAccess, que no representan tipos únicos de acceso a variables del Registro.

Se aplica a

Producto Versiones
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10