RegistryPermission.AddPathList 方法

定义

将指定的注册表变量的访问权限添加到现有的权限状态中。Adds access for the specified registry variables to the existing state of the permission.

重载

AddPathList(RegistryPermissionAccess, String)

将指定的注册表变量的访问权限添加到现有的权限状态中。Adds access for the specified registry variables to the existing state of the permission.

AddPathList(RegistryPermissionAccess, AccessControlActions, String)

将指定注册表变量的访问权限添加到现有的权限状态中,同时指定注册表权限访问和访问控制操作。Adds access for the specified registry variables to the existing state of the permission, specifying registry permission access and access control actions.

注解

使用此方法可以通过将其路径集添加到当前权限对象的状态来修改对注册表变量的访问权限。Use this method to modify access to registry variables by adding the set of their paths to the state of the current permission object.

AddPathList(RegistryPermissionAccess, String)

将指定的注册表变量的访问权限添加到现有的权限状态中。Adds access for the specified registry variables to the existing state of the permission.

public:
 void AddPathList(System::Security::Permissions::RegistryPermissionAccess access, System::String ^ pathList);
public void AddPathList (System.Security.Permissions.RegistryPermissionAccess access, string pathList);
member this.AddPathList : System.Security.Permissions.RegistryPermissionAccess * string -> unit
Public Sub AddPathList (access As RegistryPermissionAccess, pathList As String)

参数

pathList
String

注册表变量列表(用分号分隔)。A list of registry variables (semicolon-separated).

例外

access 参数不是 RegistryPermissionAccess 的有效值。The access parameter is not a valid value of RegistryPermissionAccess.

- 或 --or- pathList 参数不是有效的字符串。The pathList parameter is not a valid string.

示例

下面的代码示例演示方法的用法 AddPathList(RegistryPermissionAccess, String)The following code example shows the use of the AddPathList(RegistryPermissionAccess, String) 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 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

注解

使用此方法可以通过将添加到当前权限对象的状态来修改对注册表变量的访问权限。Use this method to modify access to registry variables by adding to the state of the current permission object.

AddPathList(RegistryPermissionAccess, AccessControlActions, String)

将指定注册表变量的访问权限添加到现有的权限状态中,同时指定注册表权限访问和访问控制操作。Adds access for the specified registry variables to the existing state of the permission, specifying registry permission access and access control actions.

public:
 void AddPathList(System::Security::Permissions::RegistryPermissionAccess access, System::Security::AccessControl::AccessControlActions actions, System::String ^ pathList);
public:
 void AddPathList(System::Security::Permissions::RegistryPermissionAccess access, System::Security::AccessControl::AccessControlActions control, System::String ^ pathList);
public void AddPathList (System.Security.Permissions.RegistryPermissionAccess access, System.Security.AccessControl.AccessControlActions actions, string pathList);
public void AddPathList (System.Security.Permissions.RegistryPermissionAccess access, System.Security.AccessControl.AccessControlActions control, string pathList);
member this.AddPathList : System.Security.Permissions.RegistryPermissionAccess * System.Security.AccessControl.AccessControlActions * string -> unit
member this.AddPathList : System.Security.Permissions.RegistryPermissionAccess * System.Security.AccessControl.AccessControlActions * string -> unit
Public Sub AddPathList (access As RegistryPermissionAccess, actions As AccessControlActions, pathList As String)
Public Sub AddPathList (access As RegistryPermissionAccess, control As AccessControlActions, pathList As String)

参数

actionscontrol
AccessControlActions

AccessControlActions 值之一。One of the AccessControlActions values.

pathList
String

注册表变量列表(用分号分隔)。A list of registry variables (separated by semicolons).

例外

access 参数不是 RegistryPermissionAccess 的有效值。The access parameter is not a valid value of RegistryPermissionAccess.

- 或 --or- pathList 参数不是有效的字符串。The pathList parameter is not a valid string.

注解

使用此方法可以通过将其路径集添加到当前权限对象的状态来修改对注册表变量的访问权限。Use this method to modify access to registry variables by adding the set of their paths to the state of the current permission object. 此重载允许您将访问控制操作指定为注册表权限访问。This overload allows you to specify the access control action as will as the registry permission access.

control参数指定是否 pathList 可以更改、查看或不能访问为指定的注册表项 (ACL) 的访问控制列表。The control parameter specifies whether the access control list (ACL) for the registry keys specified by pathList can be changed, viewed, or cannot be accessed.

重要

(ACL) 的访问控制列表描述对指定注册表项执行特定操作的权限或无权执行的个人或组。An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the specified registry keys. 更改或查看 ACL 的功能是一个重要的权限,应小心授予。The ability to change or view an ACL is an important permission and should be granted with caution.

适用于