xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

GetRegistry()

Retrieves the value of a registry entry

Syntax

GetRegistry( <nHKEY>, <cRegPath>, <cRegKey> ) --> xRegValue

Arguments

<nHKEY>
This numeric parameter specifies the root entry in the Windows registry to search for a registry key. #define constants are available in the Winreg.ch file that can be used for <nHKEY>. They begin the the prefix HKEY_.
<cRegPath>
This is a character string holding the search path in the registry to locate <cRegKey>. The path must include a backslash as delimiter, if required, but may neither begin or end with a backslash.
<cRegKey>
This is a character string holding the name of the registry key to retrieve the value for. <cRegKey> must be located underneath <cRegPath>.

Return

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.

Description

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 KeyEquivalent value
HKEY_LOCAL_MACHINE0
HKEY_CLASSES_ROOT1
HKEY_CURRENT_USER2
HKEY_CURRENT_CONFIG3
HKEY_LOCAL_MACHINE4
HKEY_USERS5

Note:  on Windows NT, 2000, XP or later, the user may need certain security rights in order to be able to read the registry.

Info

See also:QueryRegistry(), SetRegistry()
Category: Registry functions , xHarbour extensions
Header:Winreg.ch
Source:rtl\winreg.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe