C# problem updating registry

  • Thread starter Daniel Passwater via DotNetMonster.com
  • Start date
D

Daniel Passwater via DotNetMonster.com

I'm trying to update the registry using C#. This seems like it should work:

int SecurityInt = 1;

// Open registry key.
RegistryKey rk = Registry.LocalMachine;
RegistryKey subKey = rk.OpenSubKey("SOFTWARE\\Microsoft\\Cryptography\\
IEDirtyFlags\\",true);

// Update key value.
rk.SetValue("dirtiest", Convert.ToString(SecurityInt));

Does anyone see what I'm doing wrong.

Thanks.
 
A

Alex Feinman [MVP]

You migh not have sufficient privileges to write to that part of registry.
Check the GetLastError value
 
D

Daniel Passwater via DotNetMonster.com

No exception. It runs through the function and the local variables are
updated, but there's no change in the registry. It reads it just fine. It
just won't update it.
 
P

Peter Foot [MVP]

Do you call Close on the registry key? (you've not shown that in your code).

Peter
 

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