Registry vs. ini-files

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

    Registry vs. ini-files

    Hello all!

    I´m going to develop a windows smartclient and can´t find the information I
    need. Where do I store user-settings like paths, background colour and so
    on. I´ve read an article about the ups and downs of registry versus files
    but i can´t find it now. Can someone please help me?

    Thanks in advance!
    /Bobby


  • Sridhar

    #2
    Re: Registry vs. ini-files

    in my opinion, the registry should only be used when the
    nature of the application absolutely requires it.

    COM applications are an excellent example of this need. A
    COM application allows other applications to use its COM
    control through its class ID (clsid). This ID is easily
    placed in the registry by the COM server application, and
    easily retrieved by a COM client. Without a central data
    repository like the registry, writing COM apps would be
    that much harder - perhaps even impossible.

    more details you can find at

    ..aspx?tabid=10 15.

    But the best way if you are using .NET is config files.
    [color=blue]
    >-----Original Message-----
    >Hello all!
    >
    >I´m going to develop a windows smartclient and can´t find [/color]
    the information I[color=blue]
    >need. Where do I store user-settings like paths, [/color]
    background colour and so[color=blue]
    >on. I´ve read an article about the ups and downs of [/color]
    registry versus files[color=blue]
    >but i can´t find it now. Can someone please help me?
    >
    >Thanks in advance!
    >/Bobby
    >
    >
    >.
    >[/color]

    Comment

    • Richard Grimes [MVP]

      #3
      Re: Registry vs. ini-files

      Bob Olsson wrote:[color=blue]
      > Hello all!
      >
      > I´m going to develop a windows smartclient and can´t find the
      > information I need. Where do I store user-settings like paths,
      > background colour and so on. I´ve read an article about the ups and
      > downs of registry versus files but i can´t find it now. Can someone
      > please help me?
      >
      > Thanks in advance!
      > /Bobby[/color]

      Just to supplement the questions you have had so far. Microsoft is
      discouraging developers from using the registry or INI files. The problem
      with the registry is that it involves a separate 'registration' step (this
      may be hidden: occuring when the app first starts), and the data resides in
      a location other than the application directory. This means that if you move
      the app to another machine the settings don't move with it. If you uninstall
      the app, you have to remove the registry settings. INI files can be stored
      in the app directory, but they are limited due to their format, XML is far
      more flexible.

      Config files are XML files in the app directory, so you can copy or delete
      them. However, config files are read-only (the current version of the
      framework does not have a class specifically to read them, although you can
      use the XML classes). They should be treated in the same way as command line
      switches, ie, the app does not write to the config file and even if it does,
      the settings are not picked up by the app until it is restarted. (Contrast
      that to the registry and INI files, where settings can be re-read).

      Also, settings in the config file are per-app, they are not per-user as you
      are requesting. One solution is to read/write an XML file in Isolated
      Storage. On this page:
      http://www.c-sharppro.com/features/2...200309rg_f.asp I
      explain some code to do this. The downside of using isolated storage is that
      the file is not stored in the app folder, so if you move the app or delete
      it the isolated storage is not affected. (The location of the files used in
      isolated storage is a little cryptic.)

      Richard
      --
      my email evpuneqt@zicf.b et is encrypted with ROT13 (www.rot13.org)


      Comment

      Working...