Some other ways are:
- Registry
- Configuration file
- Command line options
- Environment variables
- Shared memory
Registry
Using the registry is appropriate for many kinds of configuration information. By choosing a suitable place in the registry, you can make some configuration system-wide, some configuration per-user (which doesn't sound like your application but I'll mention it anyway), or any combination of the two. Windows manages the storage of the data and provides a rudimentary way for users to edit it (regedit.exe
).
Using the registry makes it more difficult to run more than one instance of your program with different options at the same time.
Configuration file
You can store configuration information in a text file on disk. This allows you to keep the configuration in the same place (same folder) as the executable, which makes it easier to find (when using the registry, you have to tell the user where to look). Configuration files can usually be edited with a regular text editor. However, generally you will have to specify what format is to be used and to read and parse the text file, handling syntax errors if needed.
This method allows you to easily run more than one instance of your program, each with its own separate configuration file (if your app looks in its own directory for the config file, for example).
Command line options
Your program can read its configuration information from the command line, but you still have to store the data somewhere else. The command line can only support a limited amount of information before it gets unwieldy.
Environment variables
Your program could read its configuration information from environment variables. These might be variables that are set by a script that runs your programs (where you have the same problems as command line options, the data must still be stored somewhere else) or might be a globally set environment variable supplied by the system. Windows provides very primitive tools for changing the global environment, less accessible than even regedit
. This choice is not often used on Windows.
Shared memory
This is an advanced technique that requires cooperation with some other program that puts the data into shared memory. And, like many other choices, the data must still be stored somewhere else in the first place. Not recommended unless you really know you need it.