SetupSetDirectoryIdEx 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 SetupSetDirectoryIdEx function associates a directory identifier in an INF file with a specific directory.


BOOL SetupSetDirectoryIdEx(
  _In_       HINF   InfHandle,
  _In_       DWORD  Id,
  _In_       PCTSTR Directory,
  _In_       DWORD  Flags,
  _Reserved_ DWORD  Reserved1,
  _Reserved_ PVOID  Reserved2


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 zero, 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.

Flags [in]

This parameter can be set to SETDIRID_NOT_FULL_PATH (1) to indicate that the Directory does not specify a full path.


If the value of this parameter is not zero the function returns ERROR_INVALID_PARAMETER.


If the value of this parameter is not zero the function returns ERROR_INVALID_PARAMETER.

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.


SetupSetDirectoryIdEx 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 SetupSetDirectoryIdEx.

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

SetupSetDirectoryIdExW (Unicode) and SetupSetDirectoryIdExA (ANSI)

See also