|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to get the registry key permission using RegistryRight in NET2.0?Hello,
I want to get the registry key permission information whether current user has the permission to delete the registry key using RegistryRights, how to do? thank you. Public Sub AccessRegistry(ByVal rk As RegistryKey, ByVal sKey As
String, ByVal action As RegistryPermissionAccess) Dim rp As New RegistryPermission(PermissionState.None) rp.SetPathList(action, rk.Name) rp.Demand() Select Case action Case RegistryPermissionAccess.Create rk.CreateSubKey("Third Sector Technologies") Case RegistryPermissionAccess.Read Dim sk As RegistryKey = rk.OpenSubKey(sKey) Dim sValue As String = sk.GetValue("Floyd") Case RegistryPermissionAccess.Write Dim sk As RegistryKey = rk.OpenSubKey(sKey) sk.SetValue("Floyd", 1) End Select End Sub Call this code like this: Dim rk As RegistryKey = Registry.CurrentUser AccessRegistry(rk, "Third Sector Technologies", RegistryPermissionAccess.Create) Show quoteHide quote "yxq" <ga***@163.net> wrote in message news:eFZ1pQ6GHHA.924@TK2MSFTNGP02.phx.gbl... > Hello, > I want to get the registry key permission information whether current user > has the permission to delete the registry key using RegistryRights, how to > do? thank you. > > > > Thank you, how to remove and add the write permission of current user for
Registry key? Show quoteHide quote "vbnetdev" <ad***@kjmsolutions.com> дÈëÏûÏ¢ÐÂÎÅ:u2E868RHHHA.***@TK2MSFTNGP06.phx.gbl... > Public Sub AccessRegistry(ByVal rk As RegistryKey, ByVal sKey As > String, ByVal action As RegistryPermissionAccess) > Dim rp As New RegistryPermission(PermissionState.None) > rp.SetPathList(action, rk.Name) > rp.Demand() > > Select Case action > Case RegistryPermissionAccess.Create > rk.CreateSubKey("Third Sector Technologies") > Case RegistryPermissionAccess.Read > Dim sk As RegistryKey = rk.OpenSubKey(sKey) > Dim sValue As String = sk.GetValue("Floyd") > Case RegistryPermissionAccess.Write > Dim sk As RegistryKey = rk.OpenSubKey(sKey) > sk.SetValue("Floyd", 1) > End Select > End Sub > > Call this code like this: > > Dim rk As RegistryKey = Registry.CurrentUser > AccessRegistry(rk, "Third Sector Technologies", > RegistryPermissionAccess.Create) > > > "yxq" <ga***@163.net> wrote in message > news:eFZ1pQ6GHHA.924@TK2MSFTNGP02.phx.gbl... >> Hello, >> I want to get the registry key permission information whether current >> user has the permission to delete the registry key using RegistryRights, >> how to do? thank you. >> >> >> >> > > Also
Function RegistryRetrieve(parent As RegistryKey, keyName As String, valueName As String) As String ' Recursively search through each subkey of a parent key ' checking to see if a match for the keyname exist and if ' the data can be obtained from that key. Returns data upon ' match and an error message otherwise. Dim childName As String For Each childName In parent.GetSubKeyNames() Try Dim child As RegistryKey = parent.OpenSubKey(childName) Dim data As String = Nothing If child.Name.EndsWith(keyName) Then ' We found the name, try to pull out key data data = child.GetValue(valueName) Else ' No luck finding the name, try a depth-first recursive search data = RegistryRetrieve(child, keyName, valueName) End If If Not (data Is Nothing) Then Return data End If Catch ex As Exception ' Print out a message whenever we come across a ' key we don't have permissions to open Console.WriteLine((childName + ": " + ex.Message)) End Try Next childName Return Nothing End Function Show quoteHide quote "yxq" <ga***@163.net> wrote in message news:eFZ1pQ6GHHA.924@TK2MSFTNGP02.phx.gbl... > Hello, > I want to get the registry key permission information whether current user > has the permission to delete the registry key using RegistryRights, how to > do? thank you. > > > > Thank you.
Show quoteHide quote "vbnetdev" <ad***@kjmsolutions.com> дÈëÏûÏ¢ÐÂÎÅ:%23z9vKCSHHHA.1***@TK2MSFTNGP02.phx.gbl... > Also > > Function RegistryRetrieve(parent As RegistryKey, keyName As String, > valueName As String) As String > ' Recursively search through each subkey of a parent key > ' checking to see if a match for the keyname exist and > if > ' the data can be obtained from that key. Returns data > upon > ' match and an error message otherwise. > Dim childName As String > For Each childName In parent.GetSubKeyNames() > Try > Dim child As RegistryKey = > parent.OpenSubKey(childName) > Dim data As String = Nothing > If child.Name.EndsWith(keyName) Then > ' We found the name, try to pull out > key data > data = child.GetValue(valueName) > Else > ' No luck finding the name, try a > depth-first recursive search > data = RegistryRetrieve(child, keyName, > valueName) > End If > If Not (data Is Nothing) Then > Return data > End If > Catch ex As Exception > ' Print out a message whenever we come > across a > ' key we don't have permissions to open > Console.WriteLine((childName + ": " + > ex.Message)) > End Try > Next childName > > > Return Nothing > End Function > > "yxq" <ga***@163.net> wrote in message > news:eFZ1pQ6GHHA.924@TK2MSFTNGP02.phx.gbl... >> Hello, >> I want to get the registry key permission information whether current >> user has the permission to delete the registry key using RegistryRights, >> how to do? thank you. >> >> >> >> > > >
Need some help...
Why I am sick of .Net destroying/releasing objects from memory? Threading Delegate Question Retrieve Hard Disk Serial Number or othe unique PC identifier - XP & 2K Error: The transport failed to connect to the server How to Insert field and value into another grid This code demonstrates a problem using a treeview twice Looking for suggestions on how to do something slow form backimage load @ vb.net |
|||||||||||||||||||||||