How to detect the deleting permission for Registry key?

  • Thread starter Thread starter YXQ
  • Start date Start date
Y

YXQ

How to detect programmatically if current user has the deleting permission
to delete a Registry key in VS 2005? thank you very much!
 
Public Function GetAccessControl As RegistrySecurity

Dim instance As RegistryKey
Dim returnValue As RegistrySecurity

returnValue = instance.GetAccessControl
 
I am very grateful if you can give full code.

vbnetdev said:
Public Function GetAccessControl As RegistrySecurity

Dim instance As RegistryKey
Dim returnValue As RegistrySecurity

returnValue = instance.GetAccessControl
 
Be careful of the 163.com spam gang & comcast.net who are both using these
newsgroups
 
This will bomb as not accetpable. If you change it to currentuser if you
have admin success it shoudl proceed without problem.

Sub Test3()
Dim regKey As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine

Try
regKey.OpenSubKey("console",
Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree,
System.Security.AccessControl.RegistryRights.Delete).ToString()
Catch ex As Exception
MessageBox.Show("The specified access to the key was not
possible")
End Try

End Sub
 
Thank you.

vbnetdev said:
This will bomb as not accetpable. If you change it to currentuser if you
have admin success it shoudl proceed without problem.

Sub Test3()
Dim regKey As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine

Try
regKey.OpenSubKey("console",
Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree,
System.Security.AccessControl.RegistryRights.Delete).ToString()
Catch ex As Exception
MessageBox.Show("The specified access to the key was not
possible")
End Try

End Sub
 
Back
Top