RegistryPermission.GetPathList メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As RegistryPermission Dim access As RegistryPermissionAccess Dim returnValue As String returnValue = instance.GetPathList(access)
戻り値
指定した RegistryPermissionAccess を示す、レジストリ変数の (セミコロン区切りの) リスト。


このメソッドを使用して、現在のアクセス許可の状態を取得します。このメソッドは、アクセスの種類ごとに呼び出す必要があります。
![]() |
---|
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- RegistryPermission.GetPathList メソッドのページへのリンク