Results 1 to 12 of 12

Thread: Accessing Registry Settings

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Posts
    19

    Accessing Registry Settings

    I 'm trying to Create and Set values in the registry. How do I set permissions so that my program has access to do this in Vb.Net?

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    hmm i didnt know you need to set any permissions!! Have you actually tried writing to the reg?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    He might need to if the program is running of Win2000 or WinXP.
    Dont gain the world and lose your soul

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I think you can only write to the CurrentUser keys....not sure.

  5. #5
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207
    If you are talking about computer permissions then you must have administrative rights but if your talking about your program being able to write to the registry it is just a True or Flase.

    For example this is how I wrote to the registry in my last program.

    Dim GetRegKey As RegistryKey
    GetRegKey = Registry.LocalMachine.OpenSubKey("Software\Folder\Subfolder", False ) 'change to true if you need to write
    Integer1 = CInt(GetRegKey.GetValue("Intvalue", ""))
    String1 = Convert.ToString(GetRegKey.GetValue("Strvalue", ""))
    GetRegKey.Close()

    If you are writing the the registry then instead of saying someting = CInt.... then just put
    PutRegKey.SetValue("Value", "1") or PutRegKey.SetValue("Name","my name is not fred")

  6. #6
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    Hey,

    When I type

    Code:
    Dim RegKey as
    I don't get the keyword RegistryKey drop down in the autocomplete. Do I need to add a reference to it?

    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Yes, it is in the Microsoft namespace.

  8. #8
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    uh-huh!!!

    found it!

    Code:
    Dim RegKey As Microsoft.Win32.RegistryKey
    thanks
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  9. #9
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    hmmm.... now i keep getting this message:

    n unhandled exception of type 'System.NullReferenceException' occurred in App01.exe

    any ideas?
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  10. #10
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    i went into the registry and created the key manually. is there a function that says "IfExists"?
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  11. #11
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    Strangely enough, a couple of articles down in the forum list, there is:

    "Test if registry key exists"
    http://www.vbforums.com/showthread.p...hreadid=220853

  12. #12
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    sorry. hungover ..... again
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

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