Home All Groups Group Topic Archive Search About

create registry value - bug in VS?

Author
29 May 2006 1:50 PM
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

Show quoteHide quote
"Ben" <ben553***@yahoo.com> wrote in message
news:uD3px7ogGHA.5088@TK2MSFTNGP02.phx.gbl...
>I am having a problem creating a registry key.  I am using the following
> code:
>
> My.Computer.Registry.LocalMachine.CreateSubKey("Software\programalpha")
> My.Computer.Registry.LocalMachine.SetValue("loglevel", "7")
> My.Computer.Registry.LocalMachine.GetValue("loglevel")
>
> When I run the above code the programalpha key is created.  The loglevel
> value (which can hold the value of numbers between 1 and 10) does not get
> created.  What am I doing wrong?
>
> Thanks,
> Ben
>
>

Author
29 May 2006 2:04 PM
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 ?

--
Patrice

"Ben" <ben553***@yahoo.com> a écrit dans le message de news:
%23fjXGbygGHA.3***@TK2MSFTNGP03.phx.gbl...
Show quoteHide quote
>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
>
> "Ben" <ben553***@yahoo.com> wrote in message
> news:uD3px7ogGHA.5088@TK2MSFTNGP02.phx.gbl...
>>I am having a problem creating a registry key.  I am using the following
>> code:
>>
>> My.Computer.Registry.LocalMachine.CreateSubKey("Software\programalpha")
>> My.Computer.Registry.LocalMachine.SetValue("loglevel", "7")
>> My.Computer.Registry.LocalMachine.GetValue("loglevel")
>>
>> When I run the above code the programalpha key is created.  The loglevel
>> value (which can hold the value of numbers between 1 and 10) does not get
>> created.  What am I doing wrong?
>>
>> Thanks,
>> Ben
>>
>>
>
>
Author
29 May 2006 2:40 PM
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 )


--
Patrice

"Patrice" <scr***@chez.com> a écrit dans le message de news:
O%234LejygGHA.1***@TK2MSFTNGP03.phx.gbl...
Show quoteHide quote
> 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
> ?
>
> --
> Patrice
>
> "Ben" <ben553***@yahoo.com> a écrit dans le message de news:
> %23fjXGbygGHA.3***@TK2MSFTNGP03.phx.gbl...
>>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
>>
>> "Ben" <ben553***@yahoo.com> wrote in message
>> news:uD3px7ogGHA.5088@TK2MSFTNGP02.phx.gbl...
>>>I am having a problem creating a registry key.  I am using the following
>>> code:
>>>
>>> My.Computer.Registry.LocalMachine.CreateSubKey("Software\programalpha")
>>> My.Computer.Registry.LocalMachine.SetValue("loglevel", "7")
>>> My.Computer.Registry.LocalMachine.GetValue("loglevel")
>>>
>>> When I run the above code the programalpha key is created.  The loglevel
>>> value (which can hold the value of numbers between 1 and 10) does not
>>> get
>>> created.  What am I doing wrong?
>>>
>>> Thanks,
>>> Ben
>>>
>>>
>>
>>
>
>