RegistryGet

Description

Gets a value from the Windows system registry.

Syntax

RegistryGet ( key, valuename, { valuetype }, valuevariable )

Argument

Description

key

A string whose value names the key in the system registry whose value you want.

To uniquely identify a key, specify the list of parent keys above it in the hierarchy, starting with the root key. The keys in the list are separated by backslashes.

valuename

A string containing the name of a value in the registry. Each key can have one unnamed value and several named values. For the unnamed value, specify an empty string.

valuetype

A value of the RegistryValueType enumerated datatype identifying the datatype of a value in the registry. Values are:

  • RegString!—A null-terminated string

  • RegExpandString!—A null-terminated string that contains unexpanded references to environment variables

  • RegBinary!—Binary data

  • ReguLong!—A 32-bit number

  • ReguLongBigEndian!—A 32-bit number

  • RegLink!—A Unicode symbolic link

  • RegMultiString!—An unbounded array of strings

valuevariable

A variable corresponding to the datatype of valuetype in which you want to store the value obtained from the system registry for the specified key and value name.

Returns

Integer. Returns 1 if it succeeds and -1 if an error occurs. An error is returned if the datatype of valuevariable does not correspond to the datatype specified in valuetype.

Usage

Long string values (more than 2048 bytes) should be stored as files and the file name stored in the registry.

For more information about keys and value names in the system registry, see RegistrySet.

Examples

Example 1

This statement obtains the value for the name Title and stores it in the string ls_titlefont:

string ls_titlefont

RegistryGet( &

 "HKEY_LOCAL_MACHINE\Software\MyApp.Settings\Fonts", &
"Title", RegString!, ls_titlefont)

Example 2

This statement obtains the value for the name NameOfEntryNum and stores it in the long ul_num:

ulong ul_num

RegistryGet( &

 "HKEY_USERS\MyApp.Settings\Fonts", &

 "NameOfEntryNum", RegULong!, ul_num)

See also