So far, all the chapters in this book have taught you how, and why, to use the Registry tools that Microsoft provides as part of Windows 2000. For the most part, these tools are sufficient for everyday use. However, you may find it necessary to write your own tools from time to time.
Windows 2000 also provides a comprehensive set of routines that allow your programs to read, write, and modify Registry keys and values. You can also connect to remote computers’ Registries, get and set security data on keys and values, and do basically everything that RegEdt32, RegEdit, and the resource kit utilities can do. This capability is a double-edged sword: you can write programs that do exactly what you want, but the burden of properly using the Registry calls is entirely on you.
The original Registry API is defined in
winreg.h, part of Microsoft’s Win32
Software Development Kit (SDK) for NT 4.0 and Windows 95. The current
version is still part of the Win32 API, but now it lives in the
Microsoft Developer Network (MSDN) Platform SDK. There are 28
distinct routines in the Registry API, though most of them actually
have two variants: one that works with standard one-byte ASCII
strings and another that handles Unicode strings. The ASCII versions
have routine names that end in “A,” such as
RegCreateKeyA, while the Unicode versions end with
a “W,” as in
RegCreateKeyW. Macros in
winreg.h automatically map the correct variant to the routine name. ...