Valhalla Legends Forums Archive | General Programming | Registry vs. .ini

AuthorMessageTime
iago
Since people suck at going off topic in different threads, I'll just start this here:

[quote author=Zakath link=topic=9596.msg89265#msg89265 date=1100801029]
[quote author=iago link=topic=9596.msg89264#msg89264 date=1100800674]1. I format frequently, and it's much easier to back up programs that don't have a presence in the registry.[/quote]
See, I consider formatting a time consuming nuisance. I do it as infrequently as I can practically manage.
[quote]2. Programs are more easily ported to/used in Linux if they don't use the registry.[/quote]
This is a chat client that is completely based on the Windows API we're talking about here. There'd be no point in porting it to linux; it'd make far more sense to just write a new one from scratch. :P
[quote]3. It's much easier to find/edit configurations by hand if they are files.  Unless they put the files somewhere stupid. but eh.[/quote]
Pfft...what are you doing editing these things by hand, anyway? That's what the config dialog is for. :)
[/quote]

1. What if something happens and you're forced to format?  It's a real pain to get registry information over only for what you need. 

2. I'm talking about in general. 

3. There are libraries to do it for you.  I tend to use java.util.Properties, and I've seen one in VB.

And what if some setting stops the program from starting that you need to edit? 
What if you need to do a find/replace that'll change a dozen or a hundred keys? 
What if regedit gets infected with a virus, or maybe you can't run ANY programs?  If your startup file was stored as an .ini, you could easily stop the virus from starting up.

I'm sure there's other reasons, but those are good ones :)
November 18, 2004, 11:32 PM
Myndfyr
[quote author=iago link=topic=9603.msg89300#msg89300 date=1100820728]
Since people suck at going off topic in different threads
[/quote]

I know that comment was directed at me.  Bite me.  :p
November 19, 2004, 3:09 AM
iago
[quote author=MyndFyre link=topic=9603.msg89328#msg89328 date=1100833748]
[quote author=iago link=topic=9603.msg89300#msg89300 date=1100820728]
Since people suck at going off topic in different threads
[/quote]

I know that comment was directed at me. Bite me. :p
[/quote]
Also Zakath :)
November 19, 2004, 4:53 AM
Zakath
Well, it's not like there was much to say about the real thread. :P
November 19, 2004, 5:16 AM
Skywing
You can actually back up and restore the registry, in part or in whole (little known as this may be).
November 19, 2004, 6:22 AM
mynameistmp
Is this supposed to be a discussion about the pros and cons of either method of storing configuration info (registry/.ini)?

Is it only registry vs .ini , or is it more broad; binary vs plain text ?
November 19, 2004, 8:55 AM
iago
Skywing -- It's troublesome to back up the registry, though.  It's much easier when you can just copy the folders over and watch it continue to work. 
Tmp -- Meh, both is good :)

Another thing that I like that Windows programs never seem to do is store configuration files in my home folder.  Tmp actually taught me the most about this, but what's really handy is to set up Linux like:
- Install the OS on one partition, like 2gb
- Install /home on a different partition, probably another 2gb
- Install /usr/local on a third partition, make it big

Then install any software to /usr/local.  All software puts its settings in your home folder.  So if something comes up and you need to reinstall the OS (like a couple weeks ago I stupidly did a recursive chown as root from the wrong folder), I can blow out the os (format my OS partition) and reinstall it, and all my software still works!  I didn't have to reinstall Apache, I didn't have to reinstall Java, etc.  Doing that is *extremely* handy!  The only thing I lost was my /etc/passwd and /etc/hosts, which wasn't a big deal.

That's a little off the main topic, but it still applies to configuration files vs. registry.
November 19, 2004, 1:34 PM
Skywing
Actually, they probably are, you just don't realize it (the hive backing HKCU is stored in your user profile directory).
November 19, 2004, 1:54 PM
Arta
hmm, if you had lots of programs to back up, it might be easier if they all used registry: backing up a section of the registry is probably easier than finding 283723 different configuration files :)
November 19, 2004, 1:57 PM
Myndfyr
[quote author=iago link=topic=9603.msg89360#msg89360 date=1100871241]
Another thing that I like that Windows programs never seem to do is store configuration files in my home folder.  Tmp actually taught me the most about this, but what's really handy is to set up Linux like:
- Install the OS on one partition, like 2gb
- Install /home on a different partition, probably another 2gb
- Install /usr/local on a third partition, make it big
[/quote]

I realize you're comparing Windows to Linux at this point, but I thought I'd make the point that the "Designed for Windows" Logo Program requires that you use the Registry and user home folders to store settings and logs and output files.  I've followed that practice somewhat with my bot's development (which is on hold atm) -- it stores installation path in HKLM\Software\ArmaBot, and user profile path in HKCU\Software\ArmaBot.

When it starts, if you don't have a folder already in your My Documents folder called ArmaBot (or if it's beta, whatever version it is), it creates one, and stores a few different configuration settings there.  My directory structure looks like this:
--My Documents\
-----ArmaBot Beta 1\
-------ProfilesList.xml (which is just a list of the profile names, in this case, DTAAUSEast and MFUSWest).
-------DTAAUSEast\
----------ArmaBot.BinaryData.dat (user list)
----------DTAAUSEast.acp (XML file containing settings)
----------Logs\
-------------*.abl (Binary chat logs)
-------MFUSWest\
----------ArmaBot.BinaryData.dat (user list)
----------MFUSWest.acp (XML file containing settings)
----------Logs\
-------------*.abl (Binary chat logs)

This has gotten to be quite a bit off-topic, but I thought since you said that Windows apps don't do that with your home directory, I thought I'd show you that a combo of home directory settings files and registry settings would be good.  ;)
November 19, 2004, 5:15 PM
iago
Well, the reason I got into that Linux topic is because Linux doesn't have a registry, and everything uses textfiles, which I like.

Arta -- "scp -r ~ mybackupserver:/bak"
November 19, 2004, 5:18 PM
mynameistmp
One thing I don't like about configurations stored in a binary format is that you can't use simple CLI operations to edit them (unless someone has created end-user applications, which is just another layer for bugs to reside). Unrealircd configuration files can get fairly cumbersome so I typically edit them using a combination of stream editors. I could run a command like sed <oldconf >newconf -e 's/network.old.name/network.new.name/' to change the network name of the ircd. I'm not sure how you'd perform an operation like that on a configuration stored in binary format.
 
I figure by now MS must have implemented a solution for the registry creep phenomenon. Does anyone here know how they've solved it ? I was never really a fan of that either.
November 19, 2004, 8:16 PM
Kp
[quote author=Arta[vL] link=topic=9603.msg89363#msg89363 date=1100872673]hmm, if you had lots of programs to back up, it might be easier if they all used registry: backing up a section of the registry is probably easier than finding 283723 different configuration files :)[/quote]

If all the files are stored in a centralized per-user directory, either way is easy.  iago was advocating storing data in per-user areas, not in the directory to which the binary was installed.

On a related note, and somewhat addressed to Skywing: how do you backup HKCU?  I've found that it's always locked when I'm logged in, so I have to log out and relog as a dedicated backup user (whose registry I don't mind losing) just to back up *my* ntuser.dat (which holds HKCU, as I understand it).  This is annoying and I'd be happy to hear a better solution.  Ideally, Windows oughtn't be setting a no-sharing lock on the file (instead, share it read-only).
November 20, 2004, 12:16 AM
Skywing
I think you're supposed to use RegSaveKey(Ex).

Regedt32 lets you do this.
November 20, 2004, 1:40 AM
Myndfyr
[quote author=Kp link=topic=9603.msg89422#msg89422 date=1100909791]
On a related note, and somewhat addressed to Skywing: how do you backup HKCU?  I've found that it's always locked when I'm logged in, so I have to log out and relog as a dedicated backup user (whose registry I don't mind losing) just to back up *my* ntuser.dat (which holds HKCU, as I understand it).  This is annoying and I'd be happy to hear a better solution.  Ideally, Windows oughtn't be setting a no-sharing lock on the file (instead, share it read-only).
[/quote]

I just use regedit.  With HKCU (or any other part of the hive(s)) selected, go to File->Export, and you'll generate a fine text-format file containing the registry data for that branch and all sub-branches.
November 20, 2004, 1:55 AM
Kp
[quote author=MyndFyre link=topic=9603.msg89435#msg89435 date=1100915743]I just use regedit.  With HKCU (or any other part of the hive(s)) selected, go to File->Export, and you'll generate a fine text-format file containing the registry data for that branch and all sub-branches.[/quote]

Sure, but can that be re-imported later?  I only want it for merging changes after a system crash, preferably without needing a custom backup program.
November 20, 2004, 6:02 AM
iago
It'll generate a .reg file, which you can double-click to re-insert.
November 20, 2004, 7:43 AM
Skywing
You lose security, last write, and some other information with that method that makes in undesireable -- using RegSaveKey is a much better option and there's a builtin tool for it.
November 21, 2004, 6:17 PM

Search