create registry value - bug in VS?

B

Ben

I think I might have found a bug in Visual Studio.

The following code should work and doesn't:
My.Computer.Registry.LocalMachine.CreateSubKey("Software\Dravet")
My.Computer.Registry.LocalMachine.SetValue("HKEY_LOCAL_MACHINE\Software\Dravet",
"loglevel", "1")
My.Computer.Registry.LocalMachine.GetValue("loglevel")

This code does work:
My.Computer.Registry.LocalMachine.CreateSubKey("Software\Dravet")
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Dravet",
"loglevel", "1")
My.Computer.Registry.LocalMachine.GetValue("loglevel")

They are equiviant lines of code, so why doesn't the top code work? From
what I can gather from the MSDN website both pieces of code should work.

Thanks,
Ben
 
P

Patrice

And the error is ?

Also have you tried without the HKEY_LOCAL_MACHINE part as using
LocalMachine likely implies that you are already relative to this location ?
 
P

Patrice

Looks like the My NameSpace uses the same strategy i.e. keys are to be
opened/closed. Try :
With My.Computer.Registry.CurrentUser.CreateSubKey("Software\Dravet")

..SetValue("loglevel", 1)

..Close()

End With

(I'm using CurrentUser as I'm not working under an administrative account )
 

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