Pattern - The Windows Registry

Contents

The Windows Registry

The Windows registry is the core means of configuring windows applications. There is some notion of templating and inheritance – a system configuration can be defined, which can then be overridden by user-specific customisations.

Features

  • A single place to edit system settings.
  • Used ubiquitously in windows, to find other COM components, to control what gets started when windows runs, and to control the internal behaviour of windows applications.

Advantages

  • It's one place for tools and users to go to edit the settings of a system
  • Fully internationalised/Unicode enabled.
  • Hierarchical, for richer data storage.
  • Has a standard API for client applications.
  • Has a standard editor, regedit.
  • Has a standard file format , .reg, that can define additions and deletions to apply to a registry. These files can be emailed for remote registry editing.
  • Has some security; HKEY_LOCAL_MACHINE settings can only be edited by an account with the appropriate permissions.

Disadvantages

  • A Single Point of Failure. Registry corruption is not an unheard of event, and when it happens, unless a backup is available, the machine needs a complete rebuild.
  • Shared across all applications, so a change in one application can propagate to others.
  • No automated change management; no view of changes to the registry as a series of transactions which may need auditing and rollback. The registry is not a Configuration Management Database, it is merely state.
  • Badly documented.
  • Brittle. Manual editing may render a machine unusable; Software installation and removal may also have the same outcome.
  • No easy way to migrate part of a system configuration from one machine to another. Pieces of the registry can be exported and then imported, but administrators need to know which pieces to save and restore.
  • While thread-safe, bulk registry operations are not transacted. Midway through a change sequence, the system may be in an unusual state.
  • No cross-referencing of values; they need to be duplicated. This may be a factor in its brittleness.
  • You can store binary data in the registry, such as C/C++ structures at which point nobody but the specific application can safely touch those entries.

The registry debuted with OLE/COM, as a successor the simple-text, non hierarchical, .ini files of Windows 3.0. The current trend appears to be pushing developers away from using the registry as a single store of everything. A metric of its complexity is that an easy way to scare any IT support person is to call them up with a registry-related problem, such as "my machine says its registry is corrupt" or "I was editing the registry, and now I can't log in".

SmartFrog support

SmartFrog does not currently include any support for reading and writing the registry. Although there is some support in the Java Preferences API for working with the registry, this API does not offer raw access to the complete registry. Someone would need to write a JNI package with better registry integration for this. Track SFOS-604 for this work --or contribute to it!

It is possible to programmatically open .reg files during a deployment, with no GUI appearing. These can not be deleted during undeployment.

Get SmartFrog at SourceForge.net. Fast, secure and Free Open Source software downloads