RegDBSetKeyValueEx

InstallShield 2016 » InstallScript Language Reference

Project • For InstallScript MSI and Basic MSI projects, it is recommended that you use the Registry view in InstallShield instead of creating registry keys and values through InstallScript code. Handling all of your registry changes in this way allows for a clean uninstallation through the Windows Installer service.

The RegDBSetKeyValueEx function sets the value of a particular value name under a specified key in the registry.

If the value name does not already exist, RegDBSetKeyValueEx creates it. If the value data already exists, RegDBSetKeyValueEx overwrites it.

If the key does not already exist, RegDBSetKeyValueEx calls RegDBCreateKeyEx, passing the key from the szKey parameter to create it.

RegDBSetKeyValueEx is a general registry-related function, designed to work with all registry keys, including those handled by the special registry-related functions.

Note • This function supports the 64-bit parts of the registry by using the REGDB_OPTION_WOW64_64KEY option. For more information, see REGDB_OPTIONS.

Syntax

RegDBSetKeyValueEx ( szKey, szName, nType, szValue, nSize );

Parameters

RegDBSetKeyValueEx Parameters

Parameter

Description

szKey

Specifies the name of the key. Separate different levels in the subkey with a double backslash (\\).

If the root key is HKEY_CLASSES_ROOT, you do not need to specify the HKEY_CLASSES_ROOT in this parameter. Unless you specify otherwise, the InstallScript engine assumes that the value that is being set is under the key HKEY_CLASSES_ROOT. To specify a different root key, you can call RegDBSetDefaultRoot before calling RegDBSetKeyValueEx.

szName

Specifies the value name for the value data to set be set. To set the default value of the key specified in szKey, pass a null string ("") in this parameter.

nType

Specifies the type of data to be set. Pass one of the following predefined constants in this parameter:

REGDB_STRING—A string variable; no newline characters allowed.
REGDB_STRING_EXPAND—A string variable holding an expandable environment variable expression, such as "%MYPATH%".
REGDB_STRING_MULTI—A string variable; newline characters allowed.
REGDB_NUMBER—A number expressed as a string and passed in string variable. Creates data of type DWORD. When nType is REGDB_NUMBER, passing a decimal string in szValue results in a numeric value being stored in the registry. This numeric value is then displayed as a hexadecimal number followed by its decimal equivalent in parentheses. You cannot pass a hexadecimal number in the string in szValue—it must be a decimal number.
REGDB_BINARY—Binary data stored in a string.

szValue

Specifies the value to associate with the value name. All values must be passed as string variables. Numbers must be expressed as strings. The InstallScript engine converts them to numbers internally.

nSize

Specifies the size—in bytes—of the data to be set. You can specify -1 in this parameter when nType is REGDB_STRING, REGDB_STRING_EXPAND, or REGDB_NUMBER, and the InstallScript engine will set the size. However, with REGDB_BINARY and REGDB_STRING_MULTI, you must always specify the number of bytes of binary data that you are storing.

Return Values

RegDBSetKeyValueEx Return Values

Return Value

Description

0

Indicates that the function successfully set the key.

< 0

Indicates that the function was unable to set the key.

Additional Information

By default, any text that is surrounded by angle brackets—for example, "<my registry entry text>"—in this function’s string arguments is interpreted as a text substitution and is processed accordingly. To disable text substitution processing for the string arguments of registry functions, call Disable with the REGISTRYFUNCTIONS_USETEXTSUBS argument.

See Also