Results 1 to 4 of 4

Thread: Problems accesing the register

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    Problems accesing the register

    hi everyone,

    I have problems accesing the windows register, i want to create some keys (if there isn't) with this format:

    software\company\parameters
    |
    |___Variable1 Valor1
    |___Variable2 Valor2
    |___Variable3 Valor3

    I trayed with:

    dim v1 as string
    Dim key As RegistryKey = Registry.LocalMachine.CreateSubKey("Software\Company\Parameters")
    key.CreateSubKey("Variable1")
    v1 = key.GetValue("Variable1").ToString
    if v1 == Null then v1="Valor1"

    But doesn't work, any idea?
    As ever many thanks...
    Last edited by batserra; Jul 9th, 2009 at 03:09 AM.

  2. #2
    Lively Member
    Join Date
    May 2009
    Posts
    69

    Re: Problems accesing the register

    Why are you using:
    Code:
    Registry.LocalMachine.CreateSubKey("Software\Company\Parameters")
    ? The way I've always done it is simply along the lines of:
    Code:
    My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", _
                                  Application.ProductName, _
                                  Application.ExecutablePath)
    Obviously that's for booting programs on startup but you get the point. If there's some reason you've done it like you have just ignore this post but otherwise, hope I helped.

  3. #3
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Problems accesing the register

    Do something like this.

    VB.NET Code:
    1. Dim v1 As String = "Valor1"
    2.         Dim key As RegistryKey = Registry.LocalMachine.CreateSubKey("Software\Company\Parameters")
    3.         If key.GetValue("Variable1") Is Nothing Then
    4.             key.SetValue("Variable1", v1)
    5.         End If

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    Re: Problems accesing the register

    thanks a lot ,it's working !!!!
    again the best vb.net forum that exists

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width