Using Dirids

Many of the directories that appear in INF files can be expressed by using directory identifiers (dirids), which are numbers that identify specific directories. Applications can use, but cannot reassign the system-defined directories that are associated with dirids whose values are from -1 through 32767.

To create dirids with user-defined values from 32768 through 65534, or 65536 and up, use the SetupSetDirectoryId function (described in the Microsoft Windows SDK documentation).

Be aware that a dirid with a value of 65535 is considered synonymous with a dirid with a value of -1, although the latter (dirid -1) is preferred.

If you intend to use dirids in your INF file, consider the following two guidelines:

  1. When the syntax for an INF file entry explicitly specifies a dirid value (the INF DestinationDirs section, for example), express that value as a number.

    The following example demonstrates this syntax:

    [DestinationDirs]
    DefaultDestDir = 11  ;  \system32 directory on Windows 2000 and later versions
    
  2. When the syntax for an INF file entry specifies a file path, you can use a system-supplied string substitution to represent part or all of this path. This substitution has the following form:

    %dirid%

    This form consists of a percent (%) character, followed by the dirid for the directory that you want to specify, followed by another percent (%) character. A terminating backslash () character separates this expression from a following file name or additional directories in the path.

    The following example demonstrates this syntax:

    [aic78xx_Service_Inst]
    ServiceBinary = %12%\aic78xx.sys
    

    When fully expanded, the path shown in the previous example becomes c:\windows\system32\drivers\aic78xx.sys (assuming that Windows was installed in the c:\windows directory). Be aware that the string substitution, or %dirid% form, can be used anywhere a string is expected, with the exception of the INF Strings section of the INF file.

    The two following examples show how string substitution should not be used.

    [DestinationDirs]
    DefaultDestDir = %11%  ; Error! - number expected
    
    [aic78xx_Service_Inst]
    ServiceBinary = 12\aic78xx.sys  ; Error! - unknown directory name
    

    In the first example, the syntax for the DefaultDestDir entry requires its value to be a number. However, the %11% expression expands to a string. In the second example, the INF writer apparently intended to set the value for the ServiceBinary entry to a file in the directory that contains drivers (see the following table for more information). The error occurs because Windows looks for the specified file in a directory named "12", which probably does not exist on the computer.

The following table shows several commonly used dirids, and the directories they represent. The values most commonly specified by device INF files and driver INF files are listed toward the top of the table.

Value Destination Directory

01

SourceDrive:\pathname (the directory from which the INF file was installed)

10

Windows directory.

This is equivalent to %SystemRoot%.

11

System directory.

This is equivalent to %SystemRoot%\system32 for Windows 2000 and later versions of Windows..

12

Drivers directory.

This is equivalent to %SystemRoot%\system32\drivers for Windows 2000 and later versions of Windows.

13

Driver package's Driver Store directory.

For Windows 8.1 and later versions of Windows, specifies the path to the Driver Store directory where the driver package was imported.

Don't use DelFiles on a file for which DestinationDirs includes dirid 13.

The optional subdirectory in the SourceDiskFiles section for a file must match the subdirectory in the DestinationDirs section for the entry that applies to this file.

Don't use CopyFiles to rename a file for which DestinationDirs includes dirid 13.

For more information on using dirid 13, see Run from Driver Store.

17

INF file directory

18

Help directory

20

Fonts directory

21

Viewers directory

23

Color directory (ICM) (not used for installing printer drivers)

24

Root directory of the system disk.

This is the root directory of the disk on which Windows files are installed. For example, if dirid 10 is "C:\winnt", then dirid 24 is "C:\".

25

Shared directory

30

Root directory of the boot disk, also known as "ARC system partition". (This might or might not be the same directory as the one represented by dirid 24.)

50

System directory

This is equivalent to %SystemRoot%\system.

51

Spool directory (not used for installing printer drivers − see Printer Dirids)

52

Spool drivers directory (not used for installing printer drivers)

53

User profile directory

54

Directory where Ntldr.exe and Osloader.exe are located

55

Print processors directory (not used for installing printer drivers)

-1

Absolute path

Dirid values from 16384 through 32767 are reserved for special shell folders. The following table shows dirid values for these folders.

Value Shell Special Folder

16406

All Users\Start Menu

16407

All Users\Start Menu\Programs

16408

All Users\Start Menu\Programs\Startup

16409

All Users\Desktop

16415

All Users\Favorites

16419

All Users\Application Data

16422

Program Files

16425

%SystemRoot%\SysWOW64

16426

%ProgramFiles(x86)%

16427

Program Files\Common

16428

%ProgramFiles(x86)%\Common

16429

All Users\Templates

16430

All Users\Documents

In addition to the values in this table that are defined in Setupapi.h, you can use any of the CSIDL_Xxx values that are defined in Shlobj.h. To define a dirid value for a folder not listed in this table, add 16384 (0x4000) to the CSIDL_Xxx value. For more information about CSIDL_Xxx values, see the Windows SDK documentation.