create registry value - bug in VS?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    #1

    create registry value - bug in VS?

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

    The following code should work and doesn't:
    My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\Dra vet")
    My.Computer.Reg istry.LocalMach ine.SetValue("H KEY_LOCAL_MACHI NE\Software\Dra vet",
    "loglevel", "1")
    My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")

    This code does work:
    My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\Dra vet")
    My.Computer.Reg istry.SetValue( "HKEY_LOCAL_MAC HINE\Software\D ravet",
    "loglevel", "1")
    My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")

    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" <ben553335@yaho o.com> wrote in message
    news:uD3px7ogGH A.5088@TK2MSFTN GP02.phx.gbl...[color=blue]
    >I am having a problem creating a registry key. I am using the following
    > code:
    >
    > My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\pro gramalpha")
    > My.Computer.Reg istry.LocalMach ine.SetValue("l oglevel", "7")
    > My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")
    >
    > 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
    >
    >[/color]


  • Patrice

    #2
    Re: create registry value - bug in VS?

    And the error is ?

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

    --
    Patrice

    "Ben" <ben553335@yaho o.com> a écrit dans le message de news:
    %23fjXGbygGHA.3 996@TK2MSFTNGP0 3.phx.gbl...[color=blue]
    >I think I might have found a bug in Visual Studio.
    >
    > The following code should work and doesn't:
    > My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\Dra vet")
    > My.Computer.Reg istry.LocalMach ine.SetValue("H KEY_LOCAL_MACHI NE\Software\Dra vet",
    > "loglevel", "1")
    > My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")
    >
    > This code does work:
    > My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\Dra vet")
    > My.Computer.Reg istry.SetValue( "HKEY_LOCAL_MAC HINE\Software\D ravet",
    > "loglevel", "1")
    > My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")
    >
    > 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" <ben553335@yaho o.com> wrote in message
    > news:uD3px7ogGH A.5088@TK2MSFTN GP02.phx.gbl...[color=green]
    >>I am having a problem creating a registry key. I am using the following
    >> code:
    >>
    >> My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\pro gramalpha")
    >> My.Computer.Reg istry.LocalMach ine.SetValue("l oglevel", "7")
    >> My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")
    >>
    >> 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
    >>
    >>[/color]
    >
    >[/color]


    Comment

    • Patrice

      #3
      Re: create registry value - bug in VS?

      Looks like the My NameSpace uses the same strategy i.e. keys are to be
      opened/closed. Try :
      With My.Computer.Reg istry.CurrentUs er.CreateSubKey ("Software\Drav et")

      ..SetValue("log level", 1)

      ..Close()

      End With

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


      --
      Patrice

      "Patrice" <scribe@chez.co m> a écrit dans le message de news:
      O%234LejygGHA.1 276@TK2MSFTNGP0 3.phx.gbl...[color=blue]
      > And the error is ?
      >
      > Also have you tried without the HKEY_LOCAL_MACH INE part as using
      > LocalMachine likely implies that you are already relative to this location
      > ?
      >
      > --
      > Patrice
      >
      > "Ben" <ben553335@yaho o.com> a écrit dans le message de news:
      > %23fjXGbygGHA.3 996@TK2MSFTNGP0 3.phx.gbl...[color=green]
      >>I think I might have found a bug in Visual Studio.
      >>
      >> The following code should work and doesn't:
      >> My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\Dra vet")
      >> My.Computer.Reg istry.LocalMach ine.SetValue("H KEY_LOCAL_MACHI NE\Software\Dra vet",
      >> "loglevel", "1")
      >> My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")
      >>
      >> This code does work:
      >> My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\Dra vet")
      >> My.Computer.Reg istry.SetValue( "HKEY_LOCAL_MAC HINE\Software\D ravet",
      >> "loglevel", "1")
      >> My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")
      >>
      >> 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" <ben553335@yaho o.com> wrote in message
      >> news:uD3px7ogGH A.5088@TK2MSFTN GP02.phx.gbl...[color=darkred]
      >>>I am having a problem creating a registry key. I am using the following
      >>> code:
      >>>
      >>> My.Computer.Reg istry.LocalMach ine.CreateSubKe y("Software\pro gramalpha")
      >>> My.Computer.Reg istry.LocalMach ine.SetValue("l oglevel", "7")
      >>> My.Computer.Reg istry.LocalMach ine.GetValue("l oglevel")
      >>>
      >>> 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
      >>>
      >>>[/color]
      >>
      >>[/color]
      >
      >[/color]


      Comment

      Working...