Article ID: 135398
Article Last Modified on 2/2/2005
The registry is analogous to the .INI files used under Windows 3.1, with each key in the registry similar to a bracketed heading in an .INI file, and entries under the heading similar to values in the registry. However, registry keys can contain subkeys, while .INI files do not support nested headings. Registry values can also consist of executable code, rather than the simple strings representing values in .INI files. And individual preferences for multiple users of the same computer can be stored in the registry, which is not possible with .INI files.
HKEY_CLASSES_ROOT - File associations and DDE/OLE actions.
HKEY_LOCAL_MACHINE - Global information on the state of the local
computer.
HKEY_USERS - Configuration information about each individual user
of the computer and the DEFAULT entry.
HKEY_CURRENT_USER - specific key within HKEY_USERS that stores
information for the currently active user.
HKEY_CURRENT_CONFIG - Hardware configuration for devices currently attached
and installed on the computer.
HKEY_DYN_DATA - System Monitor data for performance settings and
statistics.SOFTWARE\Vendor\product\versionThe example code in this article shows one way to register an application name and version.
* REGISTRY.PRG
* This code writes information to the HKEY_LOCAL_MACHINE\SOFTWARE key.
* It creates a key called MYAPPS, and a value name called AppName that
* contains the value "SuperApp 1.0"
PUBLIC RESULT,DISPLAY
RESULT=0
DISPLAY=0
#DEFINE HKEY_LOCAL_MACHINE 2147483650 && (HKEY) 0x80000002
#DEFINE SECURITY_ACCESS_MASK 983103 && SAM value KEY_ALL_ACCESS
DECLARE RegCreateKeyEx IN ADVAPI32.DLL;
INTEGER,STRING,INTEGER,STRING,INTEGER,INTEGER,INTEGER,INTEGER @, INTEGER @
DECLARE RegSetValueEx IN ADVAPI32.DLL;
INTEGER,STRING,INTEGER,INTEGER,STRING,INTEGER
?RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\MYAPPS",0,"REG_SZ",;
0,SECURITY_ACCESS_MASK,0,@RESULT,@DISPLAY) && Returns .T. if successful
?RESULT && Returns the key handle
?DISPLAY && Returns one of 2 values:
&& REG_CREATE_NEW_KEY = 1
&& REG_OPENED_EXISTING_KEY = 2
?RegSetValueEx(RESULT,"AppName",0,1,"SuperApp 1.0",13)Additional query words: Declare DLL API
Keywords: kbhowto kbcode KB135398