INF DelReg Directive
[DDInstall] | [DDInstall.CoInstallers] | [ClassInstall32] | [ClassInstall32.ntx86] | [ClassInstall32.ntia64] | (Windows XP and later versions of Windows) [ClassInstall32.ntamd64] (Windows XP and later versions of Windows) DelReg=del-registry-section[,del-registry-section]...
A DelReg directive references one or more INF-writer-defined sections describing keys and/or value entries to be removed from the registry.
Each del-registry-section referenced by a DelReg directive has the following form:
[del-registry-section] reg-root-string,subkey[,value-entry-name][,flags][,value] reg-root-string,subkey[,value-entry-name][,flags][,value] ...
A del-registry-section can have any number of entries, each on a separate line.
Identifies the root of the registry tree for other values supplied in this entry. The value can be one of the following:
Abbreviation for HKEY_CLASSES_ROOT.
Abbreviation for HKEY_CURRENT_USER.
Abbreviation for HKEY_LOCAL_MACHINE.
Abbreviation for HKEY_USERS.
Relative root, in which keys that are specified by using this abbreviation are relative to the registry key associated with the INF section in which this DelReg directive appears, as indicated in the following table.
NF Section Containing AddReg Directive Registry Key Referenced by HKR INF DDInstall section The device's software key INF DDInstall.HW section The device's hardware key INF DDInstall.Services section The Services key
Note HKR cannot be used in an del-registry-section referenced from an INF DefaultInstall section.
For more information about driver information that is stored under the HKEY_LOCAL_MACHINE root, see Registry Trees and Keys for Devices and Drivers.
This optional value, formed either as a %strkey% token defined in a Strings section of the INF or as a registry path under the given reg-root (key1\key2\key3...), specifies one of the following:
- A subkey to be deleted from the registry at the end of the given registry path
- An existing subkey from which the given value-entry-name is to be deleted
This value identifies a named value entry to be removed from the given subkey. This value and its preceding comma should be omitted if the subkey itself is being removed from the registry.
(Windows XP and later versions of Windows.) This optional hexadecimal value, expressed as an ORed bitmask of system-defined low word and high word flag values, defines the data type for a value entry, or controls the delete-registry operation. If flags is not specified, the value-entry-name (if specified) or subkey will be deleted.
Bitmask values for each of these flags are as follows:
- 0x00002000 (FLG_DELREG_KEYONLY_COMMON)
Delete the entire subkey.
- 0x00004000 (FLG_DELREG_32BITKEY)
Make the specified change in the 32-bit registry. If not specified, the change is made to the native registry.
- 0x00018002 (FLG_DELREG_MULTI_SZ_DELSTRING)
Within a multistring registry entry, delete all strings matching a string value specified by value. Case is ignored.
(Windows XP and later versions of Windows.) Specifies a registry value, if flags indicates that a registry value is required.
A DelReg directive can be specified under any of the sections shown in the formal syntax statement above. This directive can also be specified under any of the following INF-writer-defined sections:
- A service-install-section or event-log-install section referenced by the AddService directive in an INF DDInstall.Services section.
- An add-interface-section referenced by the AddInterface directive in an INF DDInstall.Interfaces section.
- An install-interface-section referenced in an INF InterfaceInstall32 section.
In general, an INF should never attempt to delete subkeys or value entries within existing subkeys that were set up by system components or by the INF files for other devices. The purpose of a delete-registry section is to clean stale registry information from a previous installation by using a new INF file supplied by the same provider.
Each del-registry-section name must be unique to the INF file, but it can be referenced by DelReg directives in other sections of the same INF. Each section name must follow the general rules for defining section names. For more information about these rules, see General Syntax Rules for INF Files.
With operating system versions prior to Windows XP, the only way to delete a key is by specifying the following:
For Windows XP and later versions of Windows, the following is also permitted (to specify the 32-bit registry):
This example shows how the system-supplied COM/LPT ports class installer's INF removes stale NT-specific registry information about COM ports from the registry.
[ComPort.NT] CopyFiles=ComPort.NT.Copy AddReg=ComPort.AddReg, ComPort.NT.AddReg ... ; more directives omitted here [ComPort.NT.HW] DelReg=ComPort.NT.HW.DelReg [ComPort.NT.Copy] serial.sys serenum.sys [Comport.NT.AddReg] HKR,,EnumPropPages32,,"MSPorts.dll,SerialPortPropPageProvider" [ComPort.NT.HW.DelReg] HKR,,UpperFilters