Windows Driver Kit: Device Installation
INF Strings Section
[Strings] | [Strings.LanguageID] ...
 
strkey1 = ["]some string["]
strkey2 = "     string-with-leading-or-trailing-whitespace      " |
               "very-long-multiline-string " |
               "string-with-semicolon" | "string-ending-in-backslash" |
               ""double-quoted-string-value""
...
 
 

An INF file must have at least one Strings section to define every %strkey% token specified elsewhere in that INF.

Entries

strkey1, strkey2, ...
Each string key in an INF file must specify a unique name consisting of letters, digits, and/or other explicitly visible characters. A % character within such a strkey token must be expressed as %%.
some string | "some string"
Specifies a string, optionally delimited with double quotation marks characters ("), that contains letters, digits, punctuation, and possibly even certain implicitly visible characters, in particular, internal space and/or tab characters. However, an unquoted string cannot contain an internal double quotation marks ("), semicolon (;), linefeed, return, or any invisible control characters, and it cannot have a backslash (\) as its final character.
"     string-with-leading-or-trailing-whitespace      " |
"very-long-multiline-string" |
"string-with-semicolon" | "string-ending-in-backslash" |
""double-quoted-string-value""
The value specified for a %strkey% token must be enclosed in double quotation marks, if it meets any of the following criteria:
  • If a given string has leading or trailing whitespace that must be retained as part of its value, that string must be enclosed in double quotation marks characters to prevent its leading and/or trailing whitespaces from being discarded by the INF parser.
  • If a long string might contain any internal linefeed or return characters due to linewrapping in the text editor, it also should be enclosed in double quotation marks to prevent truncation of the string at the initial internal linefeed or return character.
  • If such a string contains a semicolon, it must be enclosed in double quotation marks to prevent the string from being truncated at the semicolon. (As already mentioned in General Syntax Rules for INF Files, the semicolon character begins each comment in INF files.)
  • If such a string ends in a backslash, it must be enclosed in double quotation marks to prevent the string from being concatenated with the next entry. (As already mentioned in General Syntax Rules for INF Files, the backslash character (\) is used as the line continuator in INF files.)
  • Like an unquoted string specification, such a "quoted string" cannot contain internal double quotation marks characters. However, it can be specified as an explicitly double-quoted string value by using one or more additional pairs of double quotation marks characters (for example, ""some string"").

    The INF parser not only discards the outermost pair of enclosing double quotation marks for any "quoted string" in this section, but also condenses each subsequent sequential pair of double quotation marks into a single double quotation marks character. That is, """some string""" also becomes "some string" when it has been parsed.

To summarize, any string containing leading or trailing whitespace, that is so long it linewraps, that contains a semicolon or a final backslash character, or that is itself a quoted string, must be enclosed in a pair of double quotation marks characters ("). The system INF parser discards the outermost enclosing pair of double quotation marks characters delimiting such a string, along with any leading or trailing whitespace characters outside the double quotation marks string delimiters.

Comments

Because the system INF parser strips the outermost pair of enclosing double quotation marks from any "quoted string" defining a %strkey% token, many of the system INF files define all their %strkey% tokens as "quoted string"s to avoid the inadvertent loss of leading and trailing whitespaces during INF parsing, to ensure that particularly long string values that wrap across lines cannot be truncated, and to ensure that strings with ending backslashes cannot be concatenated to the next line in the INF file.

To create a single international INF file, an INF for NT-based installations can have a set of locale-specific Strings.LanguageID sections, as shown in the formal syntax statement. The LanguageID extension is a hexadecimal value defined as follows:

  • The lower 10 bits contain the primary language ID and the next 6 bits contain the sublanguage ID, as specified by the MAKELANGID macro defined in winnt.h.
  • The language and sublanguage IDs must match the system-defined values of the Win32 LANG_XXX and SUBLANG_XXX constants defined in winnt.h.

For example, a LanguageID value of 0407 represents a primary language ID of LANG_GERMAN (07) with a sublanguage ID of SUBLANG_GERMAN (01).

An INF file can contain only one [Strings] section, along with one [Strings.LanguageID] section for each LanguageID value.

Note  Windows 9x/Me Setup does not support [Strings.LanguageID] sections.

Setup selects a single Strings section that is used to translate all %strkey% tokens for the installation. Depending on the current locale of a particular machine, Setup selects a Strings section in the following way:

  1. First, look for the .LanguageID values in the INF that match the current locale assigned to the machine. If an exact match is found, Setup uses that Strings.LanguageID INF section to translate all %strkey% tokens that are defined within the INF.
  2. Otherwise, look next for a match to the LANG_XXX value with the value of SUBLANG_NEUTRAL as the SUBLANG_XXX. If such a match is found, Setup uses that INF section to translate all %strkey% tokens that are defined within the INF.
  3. Otherwise, look next for a match to the LANG_XXX value and any valid SUBLANG_XXX for the same LANG_XXX family. If such a partial match is found, use that Strings.LanguageID INF section to translate all %strkey% tokens that are defined within the INF.
  4. Otherwise, use the undecorated Strings section to all translate %strkey% tokens that are defined within the INF.

By convention, and for convenience in creating a set of INF files for the international market, the Strings sections are the last within all system INF files. Using %strkey% tokens for all user-visible string values within an INF, and placing them in per-locale Strings sections, simplifies the translation of such strings. For additional information about locale-specific INF files, see Creating International INF Files.

Although the Strings sections are usually the last section in every INF file, any given %strkey% token defined in a Strings section can be used repeatedly elsewhere in the INF, in particular, wherever the translated value of that token is required. The system setup functions expand each %strkey% token to the specified string and then use that expanded value for further INF processing.

The use of %strkey% tokens within INF files is not restricted to user-visible string values. These tokens can be used in any manner convenient to the INF writer, as long as each token is defined within a Strings section. For example, when writing an INF file that requires the specification of several GUIDs, it might be convenient to create a %strkey% token for each GUID, using a meaningful name as a substitute for each such GUID value. Specifying a set of %strkey% = "{GUID}" values in the INF file's Strings section requires you to type each explicit GUID values only once, and it can help to provide more readable internal INF documentation than using explicit GUID values throughout the INF file.

All %strkey% tokens must be defined within the INF file in which they are referenced. Thus, for any INF file that has Include= and Needs= entries, an included INF must have its own Strings section to define all %strkey% tokens referenced in that INF.

In an INF Strings section, the maximum length, in characters, of a substitution string, including a terminating NULL character, is 4096 (Windows Vista and later versions of Windows) and 512 (Windows Server 2003, Windows XP, and Windows 2000). After string substitution, the maximum length, in characters, of an INF file string is 4096, including a terminating NULL character.

Examples

The following example shows a fragment of a Strings section from a system-supplied locale-specific dvd.inf for installations in English-speaking countries/regions.

[Strings]
Msft="Microsoft"
MfgToshiba="Toshiba"
Tosh404.DeviceDesc="Toshiba DVD decoder card"
; ... 

The following example illustrates string concatenation.

[OEM Windows System Component Verification]
OID = 1.3.6.1.4.1.311.10.3.7    ; WHQL OEM OID 
Notice = "%A% %B% %C% %D% %E%" 

[Strings]
A = "This certificate is used to sign untested drivers that have not passed the Windows Hardware Quality Labs (WHQL) testing process."
B = "This certificate and drivers signed with this certificate are intended for use in test environments only, and are not intended for use in any other context."
C = "Vendors who distribute this certificate or drivers signed with this certificate outside a test environment may be in violation of their driver signing agreement."
D = "Vendors who have their drivers signed with this certificate do so at their own risk." 
E = "In particular, Microsoft assumes no liability for any damages that may result from the distribution of this certificate or drivers signed with this certificate outside the test environment described in a vendor's driver signing agreement."

See Also

DDInstall, DDInstall.CoInstallers, DDInstall.HW, DDInstall.Interfaces, DDInstall.Services, Manufacturer, InterfaceInstall32, Models, SourceDisksNames, Version


Send feedback on this topic
Built on October 01, 2009
Page view tracker