View Single Post
ndi's Avatar
Posts: 2,050 | Thanked: 1,425 times | Joined on Dec 2009 @ Bucharest
#20
Originally Posted by juise- View Post
* Using registry to store preferences makes moving settings of some application from one PC to other a pain.
Such a lovely point you make. This is exactly what I was talking about - being unaware of options by not being a native. We have since learned to live off the land:

* There is an app in your start menu ever since XP or so that exports all settings to the network, an USB stick or disk. You can use that to import back everything after reinstall.

* Once you understand structure of registry, it's easy to do by hand. For example, I use Delphi which has a billion settings. Here's what I do:

a) Open regedit and navigate to HKEY_CURRENT_USER\Software\Borland.

HKEY_CURRENT_USER is a hive that is loaded from your profile at logon, while LOCAL_MACHINE is common to all and is loaded on boot. So, basically, common and user. Or, /urs and /home if you like.

All installed programs must use /Software by regulations. Then Company name, the program name, then ideally version or so. Thus,

HKEY_CURRENT_USER\Software\Borland

That means my settings from Borland. The hive includes Delphi, C Builder, etc. E.g. I have HKEY_CURRENT_USER\Software\Borland\Delphi for Borland Delphi.

Right click or choose File > Export. Type a name and path and a text-only version will be dumped at your location. To import, simply choose import or double-click the text file.

This isn't all. Text files have a defined syntax, so not only you can merge data, you can delete by adding a minus in front of the key. Keys and imported top to bottom, so it's possible to have a registry key be deleted then imported as is, as well as merged.

All data is text encoded and DBCS.

Basically, you can decompile any branch into a config file and back. Added bonus is registry have per-entity (value, key, etc) permissions.

But hey, what about admins you say? Well, regedit supports CLI, even if GUI app (they all do) so to export it in a script, do:

regedit.exe /e Delphi.reg HKEY_CURRENT_USER\Software\Borland

And presto. Setting dump. Import is easy. Add /s (silent) for a quick merger. Also, do mash them together, either use a text editor or concatenate via COPY (cp) command.

And yes, you can dump-import the whole software key forward and back. Also, there are tools to recover packed versions of the registry. Regedt32 (advanced version of regedit) as well as 3rd party tools like some I wrote myself has a Load Hive option, that mounts a file on disk onto a branch, much like you mount a CD drive in a folder (we have that too).

So you can get the old file from your old PC you recovered via tools and Load Hive to a key of your choosing. This becomes

HKEY_LOCAL_MACHINE\ImportedStuff\SOFTWARE\Borland

From there, export, replace, import, lather, rinse repeat.

Not difficult if you know the waters.

Originally Posted by juise- View Post
* Using registry to store preferences makes saving a version of settings of some application, and restoring them later, annoying.
See above point. Want to test out WinZip settings?

regedit /e winzip1.0.reg HKEY_CURRENT_USER\SOFTWARE\WinZip

If you want to delete they key instead of merging, add another enpty key with a minus in front of it before:

REGEDIT 5.0

[-HKEY_CURRENT_USER\SOFTWARE\WinZip]

[HKEY_CURRENT_USER\SOFTWARE\WinZip]
name="Jim"

Simple.

Originally Posted by juise- View Post
* Using registry to store preferences gives an application enough rope to hang itself so properly, that advanced registry surgeon skills are necessary to get it running again.
There is nothing complex about registry once you know how to use it. In fact, API used to work with INI files are mapped so you can switch from INI to registry and back with only a path change (in case you saw an app that allows you to do both). So, it can be used as an INI, which is, basically, a config file. Your key in the registry IS a config file, except it allows structured storage of sorts.

That is, you can use SOFTWARE\Juise-\MyStuff\Address\IP and Address\Port instead of IPAddress= and IPPort=.

Save for that, it's the same. If you strangle yourself in the registry you probably would have in a config, ini or any other saving system.

Originally Posted by juise- View Post
However, I think that currently on MS desktop OSs, it is just too complicated and too easily broken, for the amount of goodness it brings. Sadly, due to all the application legacy, many of the issues will be unfixable in the foreseeable future.
What issues, to be exact? User or developer poor understanding of the system doesn't make it a bad system. It's simply the price we pay for bringing development to all.

Originally Posted by juise- View Post
For some reason, I see nothing wrong with good old plain text config files, for application specific settings. They're robust, simple, and easily fixed when things go wrong. For OS settings, maybe some centralized DB is necessary, to allow the applications to access it in controlled manner.
Like I said, they're equivalent, one command line away. Plus, you are still free to use config files or ini files. Registry isn't mandatory. it's just fast, convenient, and PATH INDEPENDENT which is a good advantage to have when you don't have a common-root file system and can have several packages with the same name.

We don't have repos, I can have a million apps called "notepad" from several companies.

Originally Posted by juise- View Post
But, IMHO the biggest fail with registry, is the fact that it's the system and user configurations mixed together. It's just too hard to tell things apart after they've taken the blender round together.
They're not. Again I say, familiarity is key. All system settings are stored in their respective paths, and not knowing which is confusing.

Much like me not knowing the difference between /var/log and /bin, which is way, way obvious to you. One makes you cringe at the thought of rm, the other you rm on a daily bases.

Same with the registry. Each component has its path, and, because apps and OS are integrated in so many points, you can't separate them. But, e.g., things that run as programs reside in software, like everyone else because they ARE apps.

Explorer in \Software\Microsoft\Explorer (as per specs), internet explorer the same, etc. No biggie.

As for "system" stuff, like services, TCP stack, etc, they are all in LOCAL_MACHINE in their respective keys.

Originally Posted by juise- View Post
I shall end my thread de-railing efforts now, as I'm actually interested to see quality discussion on the topic at hand.
It would be interesting. Not much content thus far, but, hey, you never know

Enough OT for me, as well.
__________________
N900 dead and Nokia no longer replaces them. Thanks for all the fish.

Keep the forums clean: use "Thanks" button instead of the thank you post.
 

The Following 4 Users Say Thank You to ndi For This Useful Post: