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:
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
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:
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.
SourceDrive:\pathname (the directory from which the INF file was installed)
This is equivalent to %SystemRoot%.
This is equivalent to %SystemRoot%\system32 for Windows 2000 and later versions of Windows..
This is equivalent to %SystemRoot%\system32\drivers for Windows 2000 and later versions of Windows.
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.
INF file directory
Color directory (ICM) (not used for installing printer drivers)
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:\".
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.)
This is equivalent to %SystemRoot%\system.
Spool directory (not used for installing printer drivers − see Printer Dirids)
Spool drivers directory (not used for installing printer drivers)
User profile directory
Directory where Ntldr.exe and Osloader.exe are located
Print processors directory (not used for installing printer drivers)
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|
All Users\Start Menu
All Users\Start Menu\Programs
All Users\Start Menu\Programs\Startup
All Users\Application Data
%SystemRoot%\system32 (valid for Microsoft Win32 user-mode applications that are running under Windows on Windows (WOW64))
Program Files (valid for Win32 user-mode applications that are running under WOW64)
Program Files\Common (valid for Win32 user-mode applications that are running under WOW64)
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.