RegistryPermission.GetPathList 메서드
지정된 RegistryPermissionAccess가 포함된 모든 레지스트리 변수의 경로를 가져옵니다.
네임스페이스: System.Security.Permissions
어셈블리: mscorlib(mscorlib.dll)
‘선언
Public Function GetPathList ( _
access As RegistryPermissionAccess _
) As String
‘사용 방법
Dim instance As RegistryPermission
Dim access As RegistryPermissionAccess
Dim returnValue As String
returnValue = instance.GetPathList(access)
public string GetPathList (
RegistryPermissionAccess access
)
public:
String^ GetPathList (
RegistryPermissionAccess access
)
public String GetPathList (
RegistryPermissionAccess access
)
public function GetPathList (
access : RegistryPermissionAccess
) : String
- access
한 가지 형식의 레지스트리 변수 액세스를 나타내는 RegistryPermissionAccess 값 중 하나입니다.
지정된 RegistryPermissionAccess을 갖는 레지스트리 변수의 목록(세미콜론으로 구분된)입니다.
예외 형식 | 조건 |
---|---|
access가 유효한 RegistryPermissionAccess 값이 아닌 경우 - 또는 - access가 두 가지 형식 이상의 레지스트리 변수 액세스를 나타내는 AllAccess, 또는 어떤 형식의 레지스트리 변수 액세스도 나타내지 않는 NoAccess 중 하나인 경우 |
이 메서드를 사용하여 현재 사용 권한의 상태를 가져옵니다. 각 액세스 형식에 이 메서드를 개별적으로 호출해야 합니다.
참고
access 매개 변수는 RegistryPermissionAccess의 값으로 제한됩니다. 이 값은 한 가지 형식의 레지스트리 변수 액세스를 나타냅니다. 가능한 값은 Read, Write 및 Create입니다. NoAccess 및 AllAccess는 access의 값으로 사용할 수 없습니다. 이 두 값은 한 가지 형식의 레지스트리 변수 액세스를 나타내지 않습니다.
다음 코드 예제에서는 GetPathList 메서드를 사용하는 방법을 보여 줍니다. 이 코드 예제는 RegistryPermission 클래스에 대해 제공되는 보다 큰 예제의 일부입니다.
' 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 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 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 : " + vbLf + e.Message)
End Try
Return True
End Function 'SetGetPathListDemo
// 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 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;
}
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
2.0, 1.1, 1.0에서 지원
RegistryPermission 클래스
RegistryPermission 멤버
System.Security.Permissions 네임스페이스