The GUI INF script language provides a set of built-in commands for manipulating the configuration registry. These commands can be used in the shell or install sections of an INF script. For additional information about the registry, refer to the Windows NT Software Development Kit.
The commands that manipulate the registry create an error variable, RegLastError, whose value is set to zero if the operation succeeds, or to a nonzero error code if it fails.
The CreateRegKey command creates and returns a handle to a new key in the registry under the specified key. If the key already exists, NewHandle contains an empty string, and RegLastError is set to a nonzero value. The syntax is:
CreateRegKey KeyHandle {NewKey} Reserved Access Options NewHandle
The following example creates an XYZ key under the registry key identified by the SoftwareKey variable. If successful, NewHandle has KEY_SET_VALUE access to the new key.
CreateRegKey $(SoftwareKey) {"XYZ",0,GenericClass} "" + $(!REG_KEY_SET_VALUE) "" NewHandle
The OpenRegKey command returns an open handle to a specified registry key. If the key does not exist, NewHandle contains an empty string, and the RegLastError variable is set to a nonzero value. The syntax of the command is:
OpenRegKey KeyHandle Reserved KeyName Access NewHandle
For example:
OpenRegKey $(SoftwareKey) "" "XYZ" $(!REG_KEY_SET_VALUE) NewHandle
The FlushRegKey command writes all attributes of the specified key to the registry hives. The syntax of the command is:
FlushRegKey KeyHandle
The CloseRegKey command releases the handle of the specified key. Closing a key does not necessarily cause data to be immediately written to the registry hives. The syntax of the command is:
CloseRegKey KeyHandle
The DeleteRegKey command deletes a subkey from a key in the registry. The subkey can have values under it, but cannot have any subkeys. The syntax of the command is:
DeleteRegKey KeyHandle SubKeyName
The DeleteRegTree command deletes a key and all of its subkeys from a key in the registry. The syntax of the command is:
DeleteRegTree KeyHandle SubKeyName
The EnumRegKey command creates a list containing information about each subkey of the specified key. The syntax of the command is:
EnumRegKey KeyHandle KeyList
The SetRegValue command stores a name/value pair in the registry under the specified key. If a value with the specified name already exists, the new value replaces the old value. The syntax of the command is:
SetRegValue KeyHandle NewValueList
The GetRegValue command retrieves the value associated with a specified value name under a specified key. The syntax of the command is:
GetRegValue KeyHandle ValueName ValueData
The DeleteRegValue command deletes the name/value pair with a specified value name under a specified key. The syntax of the command is:
DeleteRegValue KeyHandle ValueName
The EnumRegValue command creates a list containing information about each name/value pair of the specified key. The syntax of the command is:
EnumRegValue KeyHandle ValueList
The Windows NT Setup program defines a number of global variables that are useful when calling the registry functions. The values assigned to these variables are the constants that can be specified in the various registry operations. For example, these global keys include a set of constants to specify the required access when opening a registry key using the OpenRegKey and CreateRegKey commands (such as REG_KEY_READ whose value is KEY_READ, a constant defined in winnt.h). You would use the $(!GlobalKey) notation (for example, $(!REG_KEY_READ) ) to use one of these predefined keys. The following is a list of these global keys and their values:
These variables can be used in any of the registry commands that require an open handle to a registry key.
"REG_H_LOCAL", HKEY_LOCAL_MACHINE "REG_H_CLASSES", HKEY_CLASSES_ROOT "REG_H_USERS", HKEY_USERS "REG_H_CUSER", HKEY_CURRENT_USER
"REG_OPT_VOLATILE", REG_OPTION_VOLATILE "REG_OPT_NONVOL", REG_OPTION_NON_VOLATILE
"REG_VT_NONE", REG_NONE "REG_VT_BIN", REG_BINARY "REG_VT_SZ", REG_SZ "REG_VT_EXPAND_SZ", REG_EXPAND_SZ "REG_VT_MULTI_SZ", REG_MULTI_SZ "REG_VT_DWORD", REG_DWORD
"REG_KEY_QUERY_VALUE", KEY_QUERY_VALUE "REG_KEY_SET_VALUE", KEY_SET_VALUE "REG_KEY_CREATE_SUB_KEY", KEY_CREATE_SUB_KEY "REG_KEY_ENUMERATE_SUB_KEYS", KEY_ENUMERATE_SUB_KEYS "REG_KEY_NOTIFY", KEY_NOTIFY "REG_KEY_READ", KEY_READ "REG_KEY_WRITE", KEY_WRITE "REG_KEY_READWRITE", KEY_READ | KEY_WRITE "REG_KEY_EXECUTE", KEY_EXECUTE "REG_KEY_ALL_ACCESS", KEY_ALL_ACCESS
"REG_ERROR_SUCCESS", 0L
The following global keys are used when creating a Services entry in the registry.
"SERVICE_KERNEL_DRIVER", SERVICE_KERNEL_DRIVER "SERVICE_FILE_SYSTEM_DRIVER", SERVICE_FILE_SYSTEM_DRIVER "SERVICE_ADAPTER", SERVICE_ADAPTER "SERVICE_WIN32_OWN_PROCESS", SERVICE_WIN32_OWN_PROCESS "SERVICE_WIN32_SHARE_PROCESS", SERVICE_WIN32_SHARE_PROCESS
"SERVICE_BOOT_START", SERVICE_BOOT_START "SERVICE_SYSTEM_START", SERVICE_SYSTEM_START "SERVICE_AUTO_START", SERVICE_AUTO_START "SERVICE_DEMAND_START", SERVICE_DEMAND_START "SERVICE_DISABLED", SERVICE_DISABLED
"SERVICE_ERROR_IGNORE", SERVICE_ERROR_IGNORE "SERVICE_ERROR_NORMAL", SERVICE_ERROR_NORMAL "SERVICE_ERROR_SEVERE", SERVICE_ERROR_SEVERE "SERVICE_ERROR_CRITICAL", SERVICE_ERROR_CRITICAL