programming with the registry

Posted on 2004-11-06
Last Modified: 2010-05-02

i'm interested in finding out about programming with the windows registry.  Does anyone know of a good general guide to using it from VB - and most importantly - what contraints there are?  i.e. I assume we're not meant to put massive amounts of information in the registry - if everyone did that it would get unstable pretty quickly wouldn't it?

is there a limit to what we should store in the registry?  Is there a guide to "good programming practices" for the registry anywhere that anyone knows of?


Question by:kenshaw
    LVL 11

    Accepted Solution

    VB comes with some simple registry readers and writers, for example:

    SaveSetting "AppName", "Section", "Key", "Data"
    ThisSetting = GetSetting"AppName", "Section", "Key")

    this has a limitation, because keys using these built-in functions are only ever stored beginning at this location:
    HKEY_CURRENT_USER\Software\VB and VBA Program Settings

    if you want to be able to read/write keys to/from different locations, you can do a private declare to a win32 api call within VB.

    some general guidelines for registry:

    - store user specific data (or machine-specific) for your app in the registry. if you must store more than 50 pieces of data, it's usually best to implement a text file or DB, so as not to clog up the registry.
    LVL 11

    Expert Comment

    small error above. should be:

    ThisSetting = GetSetting("AppName", "Section", "Key")

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now