共用方式為


RegistryPermission.AddPathList 方法

定義

將指定登錄變數的存取權加入此權限的現有狀態。

多載

AddPathList(RegistryPermissionAccess, String)

將指定登錄變數的存取權加入此權限的現有狀態。

AddPathList(RegistryPermissionAccess, AccessControlActions, String)

將指定的登錄變數存取加入權限的現有狀態,並指定登錄權限的存取和存取控制動作。

備註

使用這個方法來修改登錄變數的存取權,方法是將其路徑集新增至目前許可權物件的狀態。

AddPathList(RegistryPermissionAccess, String)

來源:
RegistryPermission.cs
來源:
RegistryPermission.cs
來源:
RegistryPermission.cs
來源:
RegistryPermission.cs

將指定登錄變數的存取權加入此權限的現有狀態。

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

登錄變數清單 (以分號分隔)。

例外狀況

access 參數不是有效的 RegistryPermissionAccess 值。

-或-

pathList 參數不是有效的字串。

範例

下列程式代碼範例示範 如何使用 AddPathList(RegistryPermissionAccess, String) 方法。

// 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

備註

使用這個方法來修改登錄變數的存取權,方法是將 新增至目前許可權物件的狀態。

適用於

AddPathList(RegistryPermissionAccess, AccessControlActions, String)

來源:
RegistryPermission.cs
來源:
RegistryPermission.cs
來源:
RegistryPermission.cs
來源:
RegistryPermission.cs

將指定的登錄變數存取加入權限的現有狀態,並指定登錄權限的存取和存取控制動作。

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 值。

pathList
String

登錄變數清單 (以分號分隔)。

例外狀況

access 參數不是有效的 RegistryPermissionAccess 值。

-或-

pathList 參數不是有效的字串。

備註

使用這個方法來修改登錄變數的存取權,方法是將其路徑集新增至目前許可權物件的狀態。 此多載可讓您指定訪問控制動作,如同登錄許可權存取一樣。

參數 control 會指定是否可以變更、檢視或無法存取 所 pathList 指定登錄機碼的訪問控制清單 (ACL) 。

重要

ACL) (存取控制清單描述具有或沒有指定登錄機碼上特定動作許可權的個人或群組。 變更或檢視 ACL 的能力是重要的許可權,應謹慎授與。

適用於