How to detect the deleting permission for Registry key?

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!
 
V

vbnetdev

Public Function GetAccessControl As RegistrySecurity

Dim instance As RegistryKey
Dim returnValue As RegistrySecurity

returnValue = instance.GetAccessControl
 
Y

YXQ

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
 
N

Newbie Coder

Be careful of the 163.com spam gang & comcast.net who are both using these
newsgroups
 
V

vbnetdev

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
 
Y

yxq

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top