Writing to the registry

  • Thread starter Thread starter stephen coleman
  • Start date Start date
S

stephen coleman

Hi all and thanks for reading this. I can read anywhere in the registry,
but I can't write to the local machine (XP Pro, I am not the admin.). My
application needs to write to the registry the registration code, but
because of the permissions thing, it won't let me. Any ideas on how I can
resolve this??

Many thanks,
Steve.
 
Steve,
Security is there for a reason so you won't be able to. Can you use the
Current User Hive or alternatively use an XML file to hold your local
settings.

Doug
 
Hi,

You need to specify you want the sub key to writeable when you
open it otherwise you get a security error.

Try

Dim hku As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.CurrentUser

Dim PreventFocus As Microsoft.Win32.RegistryKey = hku.OpenSubKey("Control
Panel\desktop", True)

PreventFocus.SetValue("ForegroundLockTimeout", 200000)

Catch ex As Exception

Trace.WriteLine(ex.ToString)

End Try



This gives security error.



Try

Dim hku As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.CurrentUser

Dim PreventFocus As Microsoft.Win32.RegistryKey = hku.OpenSubKey("Control
Panel\desktop")

PreventFocus.SetValue("ForegroundLockTimeout", 200000)

Catch ex As Exception

Trace.WriteLine(ex.ToString)

End Try



Ken

-------------------------

Hi all and thanks for reading this. I can read anywhere in the registry,
but I can't write to the local machine (XP Pro, I am not the admin.). My
application needs to write to the registry the registration code, but
because of the permissions thing, it won't let me. Any ideas on how I can
resolve this??

Many thanks,
Steve.
 
Ken,
If you read Steve's question, he is trying to write to the Local Machine
Hive without Admin Privledges.

Doug
 

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