Registry DeleteSubKey UnauthorizedAccessException ??

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

Hi

Why do i get UnauthorizedAccessException when using DeleteSubKey ?
using DeleteValue does not produce an exception.

I don't know how to solve this since the CF does noe seem to support
System.Security.Permissions.RegistryPermission

Johan
 
Does the key you're attempting to delete have any subkeys itself?
Did you open the parent with write permissions?
Is this a WM device? If so, what key are you trying to delete?
 
Hi

Its a CE5 device, only the DeleteSubkey give me an exception, same when i
try to use DeleteSubKeyTree.
I have also written the code to create all keys and values and had no
prblems with that.


This is my code :

RegistryKey regkey =
Registry.LocalMachine.OpenSubKey(@"Drivers\BuiltIn\COM1\Unimodem", true);


string[] vals = regkey.GetValueNames();

foreach (string s in vals)

{

regkey.DeleteValue(s);

}

regkey.Close();

regkey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Drivers\BuiltIn\COM1",
true);

//delete key

regkey.DeleteSubKey("Unimodem");


vals = regkey.GetValueNames();

foreach (string s in vals)

{

regkey.DeleteValue(s);

}

regkey.Close();

//remove COM1 key

regkey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Drivers\BuiltIn", true);

regkey.DeleteSubKey("COM1");

regkey.Close();
 

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

Back
Top