xHarbour Reference Documentation > Function Reference |
Retrieves the value of a registry entry
GetRegistry( <nHKEY>, <cRegPath>, <cRegKey> ) --> xRegValue
The function returns the value of the specified registry key or NIL if it does not exist within the given root entry and search path.
The function searches a key in the Windows registry beginning with the root <nHKEY>, following the search path <cRegPath>. If the key <cRegKey> exists in <cRegPath>, the value of <cRegKey> is returned. If the key cannot be found, the return value is NIL.
Winreg.ch
Winreg.ch adds quite some overhead to an application program by adding structure definitions. If this is not required, Winreg.ch does not need to be #included. GetRegistry() recognizes the following values for <nHKEY> in addition to the HKEY_* #define constants:
Registry keys
Registry Key | Equivalent value |
---|---|
HKEY_LOCAL_MACHINE | 0 |
HKEY_CLASSES_ROOT | 1 |
HKEY_CURRENT_USER | 2 |
HKEY_CURRENT_CONFIG | 3 |
HKEY_LOCAL_MACHINE | 4 |
HKEY_USERS | 5 |
Note: on Windows NT, 2000, XP or later, the user may need certain security rights in order to be able to read the registry.
See also: | QueryRegistry(), SetRegistry() |
Category: | Registry functions , xHarbour extensions |
Header: | Winreg.ch |
Source: | rtl\winreg.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example reads values from the registry as they exist // after an xHarbour Builder installation * #include "Winreg.ch" // not needed for this example #define HKEY_CURRENT_USER 0 // use alternative #define constant PROCEDURE Main LOCAL nHKey := HKEY_CURRENT_USER LOCAL cRegPath := "SOFTWARE\xHarbour.com\xHarbour Builder" ? GetRegistry( nHKey, cRegPath, "Edition" ) // result: Enterprise ? GetRegistry( nHKey, cRegPath, "rootdir" ) // result: C:\xhb ? GetRegistry( nHKey, cRegPath, "xhb build" ) // result: October 2006 RETURN
http://www.xHarbour.com