AddRegKey Method

Top  Previous  Next

Creates a registry value or changes the value of an existing value-name in the Windows Registry.

[VBScript]

Installer.AddRegKey Key, Type, Value

 

[JScript]

Installer.AddRegKey(Key, Type, Value);

Parameters

Key

String value indicating the registry value-name you want to create or change.

Type

The numeric constant identifying the registry key type (see below).

Value

The key value.

Remarks

To specify the predefined registry hive, use the following abbreviations:

"HKLM" for HKEY_LOCAL_MACHINE

"HKCR" for HKEY_CLASSES_ROOT

"HKCU" for HKEY_CURRENT_USER

"HKCC" for HKEY_CURRENT_CONFIG

Installer variables are supported in the keys and string values. To emit the value of installer variable MyVar, use the form ${MyVar}.

The following types are supported:

Constant

Windows API Name

Description

1

REG_SZ

String type. Installer variables are supported in string values.

2

REG_EXPAND_SZ

7

REG_MULTI_SZ

3

REG_BINARY

Binary data (an array of bytes). Use Arrays in VBScript and strings in JScript (see the example).

4

REG_DWORD

DWORD value (4-bytes integer).

Uninstall support

This action supports automatic uninstallation.

Example (VBScript)

Installer.AddRegKey "HKLM\Software\${CompanyName}\${ProductName}\StringValue", _

    1, "${CompanyName}"

Installer.AddRegKey "HKLM\Software\${CompanyName}\${ProductName}\DwordValue", _

    4, &HBADCAFE

' note that VBScript supports SAFEARRAYs, so you may use Array's for binary data

Dim s

s = Array( &HB, &HA, &HD, &HC, &HA, &HF, &HE )

Installer.AddRegKey "HKLM\Software\${CompanyName}\${ProductName}\BinaryValue", _

    3, s

Example (JScript)

Installer.AddRegKey("HKLM\\Software\\${CompanyName}\\${ProductName}\\StringValue"

    1, "${CompanyName}" );

Installer.AddRegKey("HKLM\\Software\\${CompanyName}\\${ProductName}\\DwordValue"

    4, 0xBADCAFE );

// JScript does not support SAFEARRAYs, so you should use strings for binary data

var s = String.fromCharCode( 0xB, 0xA, 0xD, 0xC, 0xA, 0xF, 0xE );

Installer.AddRegKey("HKLM\\Software\\${CompanyName}\\${ProductName}\\BinaryValue"

    3, s );