Using the System Registry Efficiently

[Previous] [Next]

Now that you know about the features that enable you to manipulate data in the system registry, you can learn how to make these features work in your server application. The registry should serve as the repository for your server's configuration information, but in some respects, it will also serve as a mechanism that an administrator can use to communicate configuration needs to your server.

Most servers are implemented as services, and services do not have a visible user interface. In fact, regardless of the process used to develop a server, there are compelling reasons to exclude a user interface from your server. When you exclude the user interface, you typically create a second, simple administering application to configure your service. This application can store configuration information in the registry, which your service can read. Administering applications should be able to run remotely as well as locally, and can also run on Microsoft Windows 95 or Windows 98.

When you design your service and administering application, you should follow some important rules to make the most efficient use of the system registry.

  • Your server should touch the registry as infrequently as possible. The system registry is a shared resource and access to it must be serialized. This serialization is handled by the system. Each time you call a registry function, the calling thread risks waiting while another thread is accessing the registry. This can dramatically affect the performance of an application that makes frequent registry calls. Your server should read its configuration from the registry upon startup, and optionally reread configuration information upon request by the software that is administering the server. Most services require the service to be stopped and then restarted to operate using the new configuration parameters, but this not necessary.
  • Your server should not poll the registry for changes. The system provides a means by which your service can be notified of changes made to the registry (discussed in the section "Registry Change Notifications"). Your service should use this feature as a mechanism for detecting changes made to its configuration rather than conduct a periodic polling of the system registry.
  • Avoid the temptation to report events or performance data via the registry. Your administering application and your service should avoid reporting events or performance data to nonvolatile registry keys. Instead the application and service should use the performance monitoring functionality implemented via the volatile HKEY_PERFORMANCE_DATA registry key. Please see Chapter 7 for more information about how to report performance data.


Programming Server-Side Applications for Microsoft Windows 2000
Programming Server-Side Applications for Microsoft Windows 2000 (Microsoft Programming)
ISBN: 0735607532
EAN: 2147483647
Year: 2000
Pages: 126

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net