SetupSetDirectoryId function

[This function is available for use in the operating systems indicated in the Requirements section. It may be altered or unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]

The SetupSetDirectoryId function associates a directory identifier in an INF file with a specific directory.


BOOL SetupSetDirectoryId(
  _In_ HINF   InfHandle,
  _In_ DWORD  Id,
  _In_ PCTSTR Directory


InfHandle [in]

A handle for a loaded INF file.

Id [in]

A directory identifier (DIRID) to use for an association. This parameter can be NULL. This DIRID must be greater than or equal to DIRID_USER. If an association already exists for this DIRID, it is overwritten. If Id is NULL, the Directory parameter is ignored, and the current set of user-defined DIRIDs is deleted.

Directory [in]

A pointer to a null-terminated string that specifies the directory path to associate with Id. This parameter can be NULL. If Directory is NULL, any directory associated with Id is unassociated. No error results if Id is not currently associated with a directory.

Return value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.


Indicates that a memory allocation failed.


The Id parameter is not greater than or equal to DIRID_USER, or Directory is not a valid string.


SetupSetDirectoryId can be used prior to queuing file copy operations to specify a target location that is only known at runtime.

After setting the directory identifier, this function traverses all appended INF files, and if any of them have unresolved string substitutions, the function attempts to re-apply string substitution to them based on the new DIRID mapping. Because of this, some INF values may change after calling SetupSetDirectoryId.

DIRID_ABSOLUTE_16BIT is not a valid value for Id, which ensures compatibility with 16-bit setup.


Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]







Unicode and ANSI names

SetupSetDirectoryIdW (Unicode) and SetupSetDirectoryIdA (ANSI)

See also