Export (0) Print
Expand All

RegistryPermission.GetPathList Method

Gets paths for all registry variables with the specified RegistryPermissionAccess.

Namespace:  System.Security.Permissions
Assembly:  mscorlib (in mscorlib.dll)

public string GetPathList(
	RegistryPermissionAccess access
)

Parameters

access
Type: System.Security.Permissions.RegistryPermissionAccess

One of the RegistryPermissionAccess values that represents a single type of registry variable access.

Return Value

Type: System.String
A list of the registry variables (semicolon-separated) with the specified RegistryPermissionAccess.

ExceptionCondition
ArgumentException

access is not a valid value of RegistryPermissionAccess.

-or-

access is AllAccess, which represents more than one type of registry variable access, or NoAccess, which does not represent any type of registry variable access.

Use this method to get the state of the current permission. You must call this method separately for each type of access.

NoteNote

The access parameter is limited to the values of RegistryPermissionAccess, which represent single types of registry variable access. Those values are Read, Write, and Create. The values acceptable to access do not include NoAccess and AllAccess, which do not represent single types of registry variable access.

The following code example shows the use of the GetPathList method.

// 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 occured 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;
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft