|

Windows Registry Alternative Configuration
Database COM DLL
|
Most Windows programs use the Windows
Registry to store configuration data. Did you know that starting with Windows
Vista, your application can no longer write to the
HKEY_LOCAL_MACHINE Registry key in the same way as all
previous Windows versions? Now entries are
"virtualized" into each user's own private copy, instead
of one single entry for all users, thus making it the
same as HKEY_CURRENT_USER. This is a huge
issue, as it will break many hundreds of thousands of
existing programs that write data under this key.
For this reason we have created the RegDb COM DLL as an
alternative to the Windows Registry so programs can
have their own configuration database and no longer be
dependent on these kinds of major changes that Microsoft makes.
Consider these important features:
-
Similar
function
to the Windows Registry: Has HKEY_LOCAL_MACHINE for
all users, and HKEY_CURRENT_USER for the current
user.
-
Supports
storing the same data types: String, DWORD, Binary
and also adds Float.
-
COM
interface, so you can use it from almost any
language.
-
Includes
freely distributable viewer/editor program, very similar to RegEdit (see
screenshot below).
-
Uses
industry standard SQLite relational database file as the storage file, so there is
no
worry about a proprietary file format. You can
view and edit your data using any of the many SQLite
database tools on the market, such as our SqlitePlus
Database Explorer if you wanted to.
-
Automatically
sets the file permission to allow the "All Users"
group to have full access to the RegDb file.
-
Features
encryption option, so you can easily encrypt your
values with no special programming needed.
-
Easy to
serialize .NET classes and data
-
Works with
all Windows versions Win95-Vista!
*** If you need
the Viewer-Editor to be localized to your locale, we can
send you the .rc file for you to translate - its not
large and so can be done in less than an hour.
We will make localized builds in your language from
then on ***
Almost all programs require some sort of
configuration storage. With the advent of .NET we seem to have come full circle in regard to
application settings. Back in the pre-Win95 days Microsoft invented INI
files, and told us they were good. And so they were. Then along came 95
and NT, and Microsoft said no, the registry is the way to go, forget INI
files. And so we did. Now in .NET we're told to use CONFIG files, which is
basically the same concept as an INI file, albeit being XML it’s an INI
file on steroids. Now nost programs use the Windows Registry, but some use
INI files, and others use XML files. Each have
their drawbacks. For example, you should not store
large data values in the Windows Registry, and you
cannot easily store binary data in text INI and XML files. And starting with Windows Vista, you
cannot store common data to the HKEY_LOCAL_MACHINE key
(it will make a 'virtual' copy that is for the current
user only). RegDb has none of these limitations.
Since it uses the SQLite database file as the underlying file storage, it can hold
any data type of almost any size - and its lightning fast and efficient.
Automatically Grants "All User"
Permissions
If your program only needs a .ini file you
might be thinking, "no problem, I'll just create a .ini
file in the 'All Users/Application Data' folder".
Unfortunately this won't work in all situations.
This is because if the file is created by an Admin user,
all other non-Admin users will not have "write
permission" on the file, and so cannot set any
configuration data in the file. RegDb overcomes
this by automatically changing the file permissions when
it is first created, to grant all users full access to
the file.
Usage Scenarios
Suppose you need to store configuration
data that must be updated and accessed by all users of
the machine. Your application previously used the
Windows Registry HKEY_LOCAL_MACHINE key to store this
data. Now you will use RegDb instead. You
can place your RegDb file(s) into the Windows "All
Users/Application Data" folder, so that the file will be
accessible to all users of the machine. The RegDb
COM DLL has a method named GetCommonAppDataFolder which
returns the path to this folder, so you can use it to
easily build a path to your shared RegDb file.
Here is a Visual Basic sample that
demonstrates opening a shared RegDb file and adding some
configuration data to it.
Dim
regDb As New RegDb
Dim regKey As RegKeyEnum
regDb.SetLicense( "1234567890", "" )
regDb.Open( regDb.GetCommonAppDataFolder() & "\MyAppName\test.regdb",
eRegDbFile, True )
regKey = regDb.OpenKey( eRegKeyLocalMachine, "Software/EzTools",
eRegKeyCreateSubKey, True, "")
regDb.SetValue( regKey, "My String", eRegTypeText, False, "A String
value" )
|
Very simple, isn't it? We set the license, open the file,
open a Key and set a value. Now let's see how to retrieve the value we
just set.
'assume the RegDb object is still open
Dim sVal as String
sVal =
regDb.GetValue( regKey, "My String" )
|
If anything, I think you would agree this
is even easier than using the Reg* Windows API.
You can also store values under HKEY_CURRENT_USER by
specifying eRegKeyCurrentUser in the OpenKey method.
Freely
distributable RegDb File Editor/Viewer
Of course, you also need to be able to view
(and possible hand-edit) your RegDb files, so we have
included a free utility, very similar to RegEdit.exe.
Here is a screenshot:


|
|