DELPHI和注册表,DELPHI和注册表
【 tulaoshi.com - Delphi 】
0. DISCLAIMER:
1. What is the registry?
2. What does the registry look like?
3. How to read and write data to the registry
3.1 RegCreateKey()
3.2 RegOpenKey()
3.3 RegSetValue()
3.4 RegQueryValue()
3.5 RegDeleteKey()
3.6 RegEnumKey()
4. An Example
5. Win95 features
6. REGDLL.DLL
The source code corresponding to this article is available for download as
registry.zip.
0. DISCLAIMER:
This article reflects my personal experiences with the registry and Delphi.
I had no 'real' documentation on this, except what shipped with Delphi. I
will not take any responsibility that occurs from the usage of the
procedures described in this article. The same applies to the usage of the
accompanying REGDLL.DLL and its interface. USE AT YOUR OWN RISK.
Suggestions and Comments are welcome. Please send them to:
Christian.Feichtner@jk.uni-linz.ac.at.
This article describes how to use the registry-database as an 'INI file'.
Especially with the advent of Windows 95 every 'good' windows application
should use the registry database to store its information.
Note that the described API routines are from the 16bit API. They work well
with the registry of Windows 95, but are not capable of using the special
new features of Windows 95.
1. What is the registry?
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/delphi/)The registry is a heirarchical database, which is used to store information
for the whole system. OLE-apps made frequent use of the registry in Win31.
In Windows 95 the registry has grown to more than that. It not only stores
system information but has become a total replacement for the old-style INI
files. The INI files are only supported to maintain compatibility for 'old'
16bit Apps.
2. What does the registry look like?
As mentioned above, the registry is a heirarchical database. It is
organized as a tree. The most interesting key (and the only one accessable
from Delphi with the 16bit version) is the HKEY_CLASSES_ROOT.
This key can be used to store application settings. (Thus, I think there is
another key for Windows 95 apps. Since Delphi can only access this key, you
can use it until Delphi-32 becomes avaliable).
Example:
+ HKEY_CLASSES_ROOT This is what a key could look like. Assume an
| application named Information Manager (which I'm
+--+-.IFM currently developing) which saves its files with the
|
来源:http://www.tulaoshi.com/n/20160129/1492309.html