China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-06 07:29
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Transfer an INF article... Understand INF files View 2,235 Replies 14
Original Poster Posted 2006-12-28 22:51 ·  中国 广东 河源 电信
中级用户
★★
Credits 266
Posts 98
Joined 2006-04-21 20:29
20-year member
UID 54223
Gender Male
Status Offline
I didn't find it after searching here~ Transferred over~

The INF file is full name Information File, which is a file used to describe data information such as devices or files under the Windows operating system. The INF file is composed of standard ASCII codes, and you can use any text editor to view and modify its content. Generally, we always think that the INF file is the driver program of the system device, but this is a wrong understanding. The reason why Windows prompts that an INF file is needed when installing the driver of some hardware is that the INF file provides a comprehensive description of the hardware parameters and the corresponding driver file (DLL file) information. It is just like we install computer hardware by looking at the manual. We are the Windows system, and the manual is the INF file. The INF file is very powerful and can almost complete all the functions of daily operations. You can think of it as an extremely powerful batch processing under the Windows system. To master and understand even write INF files, you need to have a considerable understanding of its internal structure. Now let's go deep into the INF file to take a look at its true face!

The composition of the INF file has three parts: sections, keys, and values.
The key sections are
version description information, mainly used for version control.
string information, used for constant definition.
define system path information.
indicate the source disk information.
indicate the source disk file name.
starts to perform installation.
Other sections can be customized. Let's use an example to specifically explain.


Program code

Signature=$Chicago$
Provider=%Author%


Product="Add file association demonstration"
Version="1.0"
Author="Xunchi"
Copyright="Copyright 2005"
CustomFile="inf" ;Modify the file name suffix you need
Program="NOTEPAD.EXE" ;Modify the application name you need to associate


HKCR,"."%CustomFile%,"",FLG_ADDREG_TYPE_SZ ,%CustomFile%File
HKCR,%CustomFile%File,"",FLG_ADDREG_TYPE_SZ,Installation information
HKCR,%CustomFile%"File\shell","",FLG_ADDREG_TYPE_SZ,open
HKCR,%CustomFile%"File\shell\open\command","",FLG_ADDREG_TYPE_SZ,%program% %1


AddReg=Add.Reg

  In the section, the "Signature" item defines in which operating system version this INF file needs to run. There are three values: $Windows NT$, $Chicago$, or $Windows 95$ for selection. Generally, $Chicago$ is selected. In the item Provider, the author of this file is defined, and %Author% refers to the value of the Author item. You can also customize other items to describe the version information of this INF file. The function of this INF file is to associate files, so it is mainly the operation of the registry. Let's look at the section, there are four statements, all in the same format. HKCR represents the root HKEY_CLASSES_ROOT, the second parameter is the path name of the subkey, the third parameter indicates the type of the value, and finally the value (specifically see the appendix). The above are all the definitions and processes of the operation. In the section , it is the process of starting to perform the installation to be installed. AddReg indicates that it is the operation on the registry, and the operation object is the definition in the Add.Reg section. If you replace AddReg with DelReg, it is to delete the key value in the registry. When you click the INF file with the mouse and select "Install" in the pop-up menu, the operation you defined starts to be executed. This example adds the view editing function in the right-click menu of the system's INF file and sets the default action. Because installing an unknown INF file may have a bad impact on the system, double-clicking the file can open and edit this file.


  Let's take a look at the capabilities of the INF file in file operations. Please see the following example.

Program code

Signature=$Chicago$
Provider=%Author%

Product="File copy and installation demonstration"
Version="1.0"
Author="Xunchi"
Copyright="Copyright 2005"


ProcessList.exe ;This file is already in the current directory, the same below.


Wordpad.exe

FileList=11 ;Install to the system directory of Windows
FileList1=10 ;Install to the Windows directory

Copyfiles=FileList,FileList1

  The role of the same section is similar to the previous example. Please pay attention to the newly appeared section , which is the section name I customized, which represents a file group, and is similar. In the section , the directory to which each file group is copied needs to be defined (the meanings of each constant are in the appendix). Copyfiles specifies the file groups that need to be copied.
  The operations of the INF file also include the installation and uninstallation of service (NT system) programs, the conversion of INI files, etc. Since these operations are relatively complex and cumbersome, and there is a certain risk, we will discuss them in depth next time when there is a chance.
  Finally, let's take a look at the execution mechanism of the INF file. At this time, you may ask, isn't it just simply executing "Install"? If you don't know why, your knowledge level will not improve. Find the "Install" command of the INF file in "Folder Options" -> "File Types" and see a string of commands. "rundll32.exe setupapi,InstallHinfSection DefaultInst_all 132 %1" It means running the command InstallHinfSection in the Dll file setupapi.dll and passing the name of the starting section DefaultInstall to it. It can be seen that the starting section can be customized. The execution of the INF file can also be used in various programming tools that support API calls. So far, we have basically understood the structure and operation mechanism of the INF file. Now let your thinking start to work and let it work better for you.


Constant definitions for registry operations:
----------------------------------------------------------
Constant Root value
HKCR HKEY_CLASSES_ROOT.
HKCU HKEY_CURRENT_USER.
HKLM HKEY_LOCAL_MACHINE.
HKU HKEY_USERS.
-----------------------------------------------------------
FLG_ADDREG_APPEND Append characters after multi-strings
FLG_ADDREG_TYPE_SZ Character type
FLG_ADDREG_TYPE_MULTI_SZ String type
FLG_ADDREG_TYPE_EXPAND_SZ Expand string type
FLG_ADDREG_TYPE_BINARY Binary value
FLG_ADDREG_TYPE_DWORD DWord value
FLG_ADDREG_TYPE_NONE NULL value
----------------------------------------------------------


Constants for the section
----------------------------------------------------------
01 Source directory (followed by path)
10 Windows directory
11 Windows system directory
12 Driver directory
17 INF file directory
18 Help file directory
20 Font directory
21 Root directory
24 Application directory
25 Shared directory
30 Current root directory
50 System directory
51 Spool directory
52 Spool driver directory
53 User configuration directory
----------------------------------------------------------

Operations defined in the section
----------------------------------------------------------
LogConfig Log file configuration
Copyfiles Copy files
Renfiles Rename files
Delfiles Delete files
UpdateInis Update Inis
UpdateIniFields Update Ini fields
AddReg Add registry items
DelReg Delete registry items
Ini2Reg Convert Ini file to Reg file
----------------------------------------------------------







Functions of INF

1 Copy files, delete files, or rename files.
2 Add or delete items in the registry.
3 Modify important system setting files (such as Autoexec.bat, Config.sys, .INI, etc.)

Rules of INF

INF is a plain text file, which is sectional, similar to the INI file. Each section is enclosed by "". The longest length of each section name is 255 characters (in Windows 2000/XP/2003 operating systems) or 28 characters (in Windows 98 operating system). The content between sections is called entries. Each section is composed of many entries. Each entry is separated by =, such as a="b". If there are multiple values after the equal sign of each entry, each value is separated by ",". INF is not case-sensitive. The line comment statement command is ";", similar to ’ in VB. If a line cannot be written down, use "\" to wrap the line.

Running of INF

The .INF file is a script file executed by the Windows SetupAPI. Its running process is very simple, which is a linear execution. The meaning of linear is that there are no branch statements in the running process of the .INF file, that is, no conditional statements. Once execution starts, it runs along a fixed route. Its running is executed in units of sections. It starts from a certain section and executes the entries in this section from top to bottom. If this entry is a section, it executes the entries in the sub-section one by one, and so on recursively. To run on WINDOW, just right-click this file and click Install.

Syntax structure of INF

; Specify the version and signature section

; The system checks whether it is suitable for the current version according to Signuture. If it is suitable, it will execute; otherwise, it will not execute. Of course, forced installation is possible
; For WIN9X
Signature="$CHICAGO$"
; WINNT+
; Signature="$Windows NT$"
; Specify the installation file layout. This line is optional. If the layout information file is not provided, the and sections must be included in the INF file
LayoutFile=filename.inf
section
The section lists the disk sequence code, disk descriptor, disk volume label, and disk serial number where the source file is located.
The syntax of the statements in the section is:
disk-ordinal=“disk-description”,disk-label,disk-serial-number
Among them, disk-ordinal is a required option, which is the disk sequence code, identifies a source disk, and is unique. Generally, it can be set to an integer incremented from 1. 0 is not a valid disk sequence code. When there are multiple source disks, the disk sequence codes cannot be repeated.
disk-description is a required option, which is the disk descriptor, a string or string macro enclosed in double quotes to describe the content or purpose of the disk. The installation engine displays this string in the dialog box to prompt the user.
disk-label is the volume identifier of the source disk.
disk-serial-number is not used, but must be set to 0.
section
The section specifies the source file used during installation and the disk sequence code and disk descriptor. The syntax of the statements in the section is:
file-name=disk-number
Among them, file-name is a required option, which is the name of the file on the source disk.
disk-number is the disk sequence code of the source disk where the file specified by file-name is located. This disk sequence code needs to be listed in the section and is greater than or equal to 1.
Subdir is an optional option, specifying the subdirectory of the source disk where the file is located. If omitted, the source disk is the default installation path.
file-size is an optional option, indicating the size of the file in bytes.


; Specify the default operation directory for the CopyFiles, RenFiles or DelFiles entry
; Syntax file-list-section=LDID,
; LDID list is as follows:
; 01 ;current directory
; 04 ;backup directory
; 10 ;windows directory
; 11 ;system dir
; 12 ;iosubsys
; 13 ;command
; 14 ;control panel directory
; 15 ;printers directory
; 16 ;workgrou dir
; 17 ;inf dir
; 18 ;help dir
; 19 ;administration dir
; 20 ;fonts
; 21 ;viewers
; 22 ;vmm32
; 23 ;color dir
; 25 ;shared dir
; 26 ;winboot
; 28 ;host winboot
; 30 ;root of boot drive
; 31 ;root of host drive of a virtual boot drive
; 32 ;old windows dir if exists

; The following example is to install to the window\web directory
; DefaultDestDir=10,"web"
; The section provides an overview of the installation process of an INF file. It identifies the detailed actions of other sections in the file that contain installation information. It is the real entry for the built-in installation function in Windows to identify the installation process and content

; The section is divided into two types: and
; The section name DefaultInstall of the section is explicitly specified in the registry as described in the previous table.
; This section is also the primary entry for the system to obtain the installation information in the INF file. When the user right-clicks the INF file and selects "Install", the content of this section is executed.
; follows the same syntax as the section, but must be explicitly called, and is often used to define the uninstall action

; Default installation section

; Specify the sub-section to add the registry. The custom section name after the equal sign, see the section for an example
ADDREG=add

; Specify the sub-section to delete the registry. The custom section name after the equal sign
DELREG=del

; Specify the file sub-section to be copied, used for installation. The Copyfiles command can replace the file that the system is accessing. These functions cannot be achieved through ordinary del and copy commands
CopyFiles=cfile

; Specify the file sub-section to be deleted, used for uninstallation. Multiple sections are separated by commas. If the command finds that the file to be deleted is locked, it will put the file in the system deletion queue and wait.
; When the system restarts, this file will be automatically deleted
DelFiles=Delete file segment
;
; File name list
; Example:
;a.exe
;b.sys
;Rename file segment
;RenFiles=Rename file segment
;
; Syntax:
;
; new-file-name,old-file-name
; file1,file2 ;Rename file file1 to file2

; Update INI file segment content sub-section
UpdateInis = Update INI file segment
;
; ini-file, ini-section, , ,
; ini-file .ini file name containing the entry to be changed
; ini-section section name containing the entry to be changed
; old-ini-entry optional, commonly used form is Key=Value
; new-ini-entry optional, commonly used form is
; Key=Value. flags is an optional operation flag
; Example
;%01%\wincmd.ini, Configuration,,"InstallDir=%01%"
;%01%\wincmd.ini, Configuration,,"Mainmenu=%01%\LANGUAGE\TCExtMenu.mnu"
; Update ini file value content
updateinifield =
; Ini file updates registry
ini2reg=aa.ini
; Update config.sys content
updatecfgsys=Update autoexec.bat segment

; Update autoexec.bat content
updateautobat=Update autoexec.bat segment


; Define resource section, like resource files. When called, %REG_SZ% represents 0x00000000

REG_SZ=0x00000000
REG_BINARY=0x00000001
REG_DWORD=0x00010001
; Custom section to add registry items

; Note the format: HKEY (root key abbreviation), Subkey (subkey), Valuename (key value name), Type (key value type), Value (key value)
; HKCU -> HKEY_CURRENT_USER
; HKCR -> HKEY_CLASSES_ROOT
; HKLM -> HKEY_LOCAL_MACHINE
; HKU -> HKEY_USERS
; HKU -> HKEY_USERS
; HKCC -> HKEY_CURRENT_CONFIG
; HKDD -> HKEY_DYN_DATA
; Unlock registry editor
HKCU,Software\Microsoft\Windows\CurrentVersion\Policies\System,DisableRegistryTools,1,0
; Unlock Internet options of IE
HKCU,Software\Policies\Microsoft\Internet Explorer\Restrictions,NoBrowserOptions,1,0
; Unlock various specific options in Internet options of IE
HKCU,Software\Policies\Microsoft\Internet Explorer\Restrictions,NoBrowserOptions,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Settings,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,HomePage,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,GeneralTab,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Cache,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,History,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Colors,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Fonts,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Languages,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Accessibility,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,SecurityTab,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,SecChangeSettings,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,SecAddSites,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,ContentTab,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Ratings,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Certificates,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,CertifPers,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,CertifSite,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,CertifPub,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,FormSuggest,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,FormSuggest Passwords,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Wallet,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Profiles,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,ConnectionsTab,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Connection Wizard,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Connwiz Admin Lock,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Connection Settings,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Proxy,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,AutoConfig,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,ProgramsTab,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,ResetWebSettings,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Check_If_Default,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,AdvancedTab,1,0
HKCU,Software\Policies\Microsoft\Internet Explorer\Control Panel,Advanced,1,0
; Unlock download (can be used alone)
HKCU,Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3,1803,1,0
; Automatically modify IE title bar text, homepage, search page, etc.
HKCU,Software\Microsoft\Internet Explorer\Main,Window Title,0,"Internet Explorer"
HKCU,Software\Microsoft\Internet Explorer\Main,Start Page,0,"http://www.zmn120.net

HKCU,Software\Microsoft\Internet Explorer\Main,Search Page,0,"http://www.zmn120.net
HKCU,Software\Microsoft\Internet Explorer\Main,Default_Page_URL,0,"http://www.zmn120.net
HKLM,SOFTWARE\Microsoft\Internet Explorer\Main,Default_Search_URL,0,"http://www.zmn120.net

HKLM,SOFTWARE\Microsoft\Internet Explorer\Main,Search Page,0,"http://www.zmn120.net

HKLM,SOFTWARE\Microsoft\Internet Explorer\Main,Start Page,0,"http://www.zmn120.net
HKLM,SOFTWARE\Microsoft\Internet Explorer\Main,Default_Page_URL,0,http://www.zmn120.net
HKLM,SOFTWARE\Microsoft\Internet Explorer\Main,Default_Page_URL,0,http://www.zmn120.net


; This section defines the list of files to be deleted. 1 after filename is a flag, indicating that if the file cannot be deleted currently, it will be deleted after the system restarts.
; Format: filename,,,1
; Example:
a.exe,,,
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
redtek +7 2006-12-28 22:56
lxmxn +8 2006-12-29 00:33
rochan +2 2006-12-29 03:31
baomaboy +2 2007-01-24 02:12
纵是千年万年 亦难以忘记
Floor 2 Posted 2006-12-28 23:06 ·  中国 北京 东城区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Thanks to the LZ! Collected~~~
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 3 Posted 2006-12-29 00:33 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  Not bad, I also searched. Thanks to the landlord.
Floor 4 Posted 2006-12-29 03:15 ·  中国 广东 河源 电信
中级用户
★★
Credits 266
Posts 98
Joined 2006-04-21 20:29
20-year member
UID 54223
Gender Male
Status Offline
### Definition of Installation Information File (.inf)

Source: Yi Wei

The basic .inf file contains the following sections (more complex .inf files may have other sections). The section names in bold are reserved keywords. The section names in italics are arbitrary names created by the .inf author:

Version section
Install section
Copy File section (CopyFiles)
Rename Files section (RenFiles)
Delete Files section (DelFiles)
Update .ini File section (UpdateInis)
Update .ini Fields section (UpdateIniFields)
Add Registry section (AddReg)
Delete Registry section (DelReg)
Add Ini File to Registry section (Ini2Reg)
Update Config.sys section (UpdateCfgSys)
Update Autoexec.bat section (UpdateAutoBat)
DestinationDirs section
SourceDisksNames section
SourceDisksFiles section
Strings section
Optional Components section
[Version] is used to confirm the basic version information of the .inf file.
[DefaultInstall] By default, the Installation section will be executed. Contains pointers to other sections, which can be used to specify files to be copied and deleted, updates to the registry, updates to the .inf file, etc.
[OtherInstall] Uses the same format as the [DefaultInstall] section, but must be explicitly called. Helps define how the component is uninstalled.
[DestinationDirs] Specifies the location on the hard disk where the section files are copied, deleted, or renamed (for example, \Windows or Windows\System)
[FileCopy/Delete/RenameSection(s)] Lists the files to be copied, deleted, or renamed.
[RegistryUpdateSection(s)] Specifies the items to be added or deleted in the registry.
[IniFileUpdateSection(s)] Specifies the update of the .ini file. Links will be created in this section.
[SourceDisksNames] Lists the disks containing the files.
[SourceDisksFiles] Lists the specific disks where each file is located.
[Strings] Lists the localizable strings used above.
Return to the beginning of the file
Version section
[Version]
Signature="$Chicago$"
LayoutFile=filename.inf
Defines the standard header information for all Windows .inf files. Note that if the signature is not $Chicago$, Windows will not accept the .inf file as an .inf file for any device type recognized by Windows.

Note that the recognition of the signature string is case-insensitive. For example, both $Chicago$ and $CHICAGO$ can be used.

filename.inf
Names the .inf file that contains the layout information (source disks and files) required to install the component. This line is optional. If not given elsewhere, the SourceDisksNames and SourceDisksFiles sections must be given in this .inf file.

The following shows a typical example of a Version section:

[Version]
Signature="$CHICAGO$"
Install section
[install-section-name]
Copyfiles = file-list-section[,]...
Renfiles = file-list-section[,file-list-section]...
Delfiles = file-list-section[,file-list-section]...
UpdateInis = update-ini-section[,update-ini-section]...
UpdateIniFields = update-inifields-section[,update-inifields-section]...
AddReg = add-registry-section[,add-registry-section]...
DelReg = del-registry-section[,del-registry-section]...
Ini2Reg = ini-to-registry-section[,ini-to-registry-section]...
UpdateCfgSys = update-config-section
UpdateAutoBat =update-autoexec-section

Identifies other sections in the .inf file that contains component installation information.

In the Install section, not all the item types shown in the above syntax are required. If a certain item type has been used, the name of the section must be specified in the .inf file. (CopyFiles entry is an exception, which can copy a single file with the file name with the "@" character without specifying the section name.) The section name must be composed of printable characters.

In any Install section, only one type of item can be used. Multiple section names can be listed in one item, but a comma must be placed before each additional name.

install-section-name
If the Install section is named [DefaultInstall], when you right-click the .inf file and then click "Install", it will run. This is also the section that will be executed when the .inf file is selected as an installation option using the Cabpack wizard.

The following shows a typical example of an Install section. It contains Copyfiles and AddReg items, which can identify sections that contain information about which files to install.

[MyApplication]
Copyfiles=MyAppWinFiles, MyAppSysFiles, @SRSutil.exe
AddReg=MyAppRegEntries
Please note that in this example, by renaming the [MyApplication] section to [DefaultInstall], when you right-click the .inf file and click the "Install" command, the Install section will be executed.

The CopyFiles item provides a special symbol that allows copying a single file directly from the copy line. A single file can be copied by prefixing the file name with the @ symbol. The target directory of the file copied using this symbol is DefaultDestDir, which is defined in the DestinationDirs section. The following is an example of how to copy a single file:

CopyFiles=FileSection1,@myfile.txt,@anotherfile.txt,LastSectionName


file42, file52, and file62), the logical drive numbers shown in the SourceDisksFiles section must be defined in the SourceDisksNames section.
纵是千年万年 亦难以忘记
Floor 5 Posted 2006-12-29 03:16 ·  中国 广东 河源 电信
中级用户
★★
Credits 266
Posts 98
Joined 2006-04-21 20:29
20-year member
UID 54223
Gender Male
Status Offline
Installation Information File (.inf) Definition

Copy Files Section (CopyFiles)
[CopyFiles-section-name]
destination-file-name[, source-file-name][,temporary-file-name][,flag]
[destination-file-name[,source-file-name][, temporary-file-name]][,flag]


Lists the file names to copy from the source disk to the destination directory. The source disk and the destination directory associated with each file are specified in other sections of the .inf file. The file-list-section name must appear in the CopyFiles entry of the Install section.

Please note that you can specify copying a single file in the CopyFiles entry of the Install section itself without generating a CopyFiles section. To do this, use the special character "@" to force copying a single file. Examples of using the "@" character in CopyFiles-type entries in the Install section reference topic are included. Using this method to copy a single file has some limitations, because the source file name and the destination file name must be the same in this case, and temporary files cannot be used.

destination-file-name
Destination file name. If no source file name is given, it is also the source file name.

source-file-name
Source file name. The source file name for the file copy operation does not have to be exactly the same as the destination file name.

temporary-file-name
Temporary file name for the file copy operation. The installer will copy the source file but give it a temporary file name. The next time the operating system is started, the temporary file name will be renamed to the destination file name. This feature is useful when copying files to a destination file that is open or in use by Windows.

flag
Optional parameter used to perform special operations during installation. Combination flags can be created by adding flag values, and multiple flags can be used. The following valid flags can be used:

1 On CopyFiles: Warn the user when they attempt to skip the file.
1 On DelFiles: If the file is in use, delete the queued delay in Wininit.ini, otherwise the currently used file cannot be deleted.
2 Critical installation: Do not allow the user to skip the file.
4 Ignore version check and always copy the file. This will overwrite the newer file.
8 Force renaming. The installer treats the file as a file in use. This only happens if the file already exists on the user's computer.
16 Do not copy if the file is already on the target computer.
32 Suppress the version conflict dialog and do not overwrite the newer file.

Here is an example of copying three files:

[CopyTheseFilesSec]
file11 ; Copy file11
file21,file22,file23 ; Copy file22, temporarily named file 23
file31,file32 ; Copy file 32 to file31
All source file names used in this example must be defined in the SourceDisksFiles section, and the logical drive numbers appearing in the SourceDisksFiles section must be defined in the SourceDisksNames section. Alternatively, the Layout.inf file can be used to provide this information.


Return to the beginning of the file

Rename Files Section (RenFiles)
[rename-files-section-name]
new-file-name, old-file-name
.
.
Lists the file names to be renamed. This section name must appear in the Renfiles entry of the Install section in the .inf file.

new-file-name
New file name.

old-file-name
Old file name.

The following example renames file42 to file41, file52 to file51, and file62 to file61:

[RenameOldFilesSec]
file41, file42
file51, file52
file61, file62
All old file names (file42, file52, and file62) used in this example must be defined in the SourceDisksFiles section, and the logical drive numbers shown in the SourceDisksFiles section must be defined in the SourceDisksNames section.


Return to the beginning of the file

Delete Files Section (DelFiles)
[ file-list-section]
file-name[,,,flag]
.
.
Lists the file names to be deleted in the DelFiles section. The file-list-section name must appear in the Delfiles entry of the Install section.

file-name
Identifies the file to be deleted.

flag
Optional parameter used to force Windows to delete the file named in this item if the file is in use during installation. To instruct Windows to queue the file deletion operation until the computer restarts, set the value of the flag parameter to 1. If a file with flag=1 cannot be deleted because it is in use, the system will restart after the device installation is complete.

If the flag parameter with a value of 1 is not used with the file-name parameter, the file cannot be deleted from the computer if it is in use when the DelFiles section is executed.

Here is an example of deleting three files:

[DeleteOldFilesSec]
file1
file2
file3

Return to the beginning of the file

Update .ini File Section (UpdateInis)
[ update-ini-section-name]
ini-file,ini-section,[old-ini-entry], [new-ini-entry], [flags]
.
.
Replaces, deletes, or adds entire entries in the given .ini file. The section name update-ini-section-name must appear in the UpdateInis entry of the Install section in the .inf file.

ini-file
Name of the .ini file containing the entry to be changed. For detailed information on specifying the .ini file name, see the following notes.

ini-section
Name of the section containing the entry to be changed.

old-ini-entry
Optional. Usually in the form Key=Value.

new-ini-entry
Optional. Usually in the form Key=Value. Both the main entry or the value can specify an alternative string. For example, the main entry or value specified in the new-ini-entry parameter may be %String1%, and the string to replace %String1% is defined in the Strings section of the .inf file.

flags
Optional operation flag. Can be one of the following values:

0 Default. If there is a main entry of old-ini-entry in the .inf file entry, replace the entry with new-ini-entry. Note that the main entry of the old-ini-entry parameter must match the .inf file entry; the value of each entry is ignored.
To unconditionally add new-ini-entry to the .ini file, set old-ini-entry to NULL. To unconditionally delete old-ini-entry from the .inf file, set new-ini-entry to NULL.

1 If there is a main entry and value of old-ini-entry in the .inf file entry, replace the entry with new-ini-entry. Note that the main entry and value of the old-ini-entry parameter and the .inf file entry must match for replacement. In contrast, using operation flag value 0, replacement is only done if the main entry matches it.
2 If the main entry of the old-ini-entry parameter does not exist in the .inf file, no operation is performed in the .ini file.
If there is a main entry of the old-ini-entry parameter in the .inf file entry and a main entry of the new-ini-entry parameter in the .ini file entry, the .inf file entry matching the new-ini-entry parameter main entry is deleted, and the .inf file entry matching the old-ini-entry parameter is processed as follows: Replace the .inf file entry main entry with the new-ini-entry parameter main entry.

If there is a main entry of the old-ini-entry parameter in the .inf file and no main entry of the new-ini-entry parameter in the .ini file, add the entry to the .inf file composed of the new-ini-entry parameter main entry and the old value.

Please note that whether the old-ini-entry parameter matches the .ini file entry depends on the main entry itself, not the main entry and value.

3 Except that the old-ini-entry parameter and the entry in the .inf file match depending on the main entry and value, not just the main entry, the other aspects are the same as the flag parameter value 2 listed above.

Asterisk (*) wildcards can be used when specifying the main entry and value, and this symbol will be interpreted correctly.

The ini-file name must be a string or a string main entry. The form of the string main entry is %strkey%, where strkey is defined in the Strings section of the .inf file. In any case, the name must be a valid file name.

The name should include the name of the folder where the file is located, but the folder name should be specified by the logical directory identifier (LDID), not the actual name. The installer will replace the LDID with the actual name during installation.

The form of LDID is %ldid%, where ldid is a predefined identifier or an identifier defined in the DestinationDirs section. Note that the constants LDID_BOOT and LDID_BOOTHOST are replaced, adding a backslash to the path. For example, LDID_BOOT is replaced with C:\. However, backslashes can be used or not in the .inf file. For example, in the root of the boot drive, you can use "%30%boot.ini" and "%30%\boot.ini" to refer to BOOT.ini.

The following example illustrates a single item in the Update .ini File section of the .inf file:

%11%\sample.ini, Section1,, Value1=2 ; Add new item
%11%\sample.ini, Section2, Value3=*, ; Delete old item
%11%\sample.ini, Section4, Value5=1, Value5=4 ; Replace old item
The following group of items in the ".inf file "Update .ini File-type" section operate with the Boot section in SYSTEM.ini. The flags parameter that forces the inclusion of the .inf file item is used to add the entry "comm.drv=comm.drv" to the Boot section, unless there are entries "comm.drv=*vcoscomm.drv" or "comm.drv=*r0dmdcom.drv" in the Boot section, in which case the existing entry is retained and the entry "comm.drv=comm.drv" is not added to the .ini file. In other words, after executing the four .inf file entries shown below, there will be a "comm.drv=" entry in the Boot section of the .inf file: "comm.drv=*vcoscomm.drv", "comm.drv=*r0dmdcom.drv", or "comm.drv=comm.drv".

system.ini, boot, "comm.drv=*vcoscomm.drv","~CommDrvTemp~=*", 3
system.ini, boot, "comm.drv=*r0dmdcom.drv","~CommDrvTemp~=*", 3
system.ini, boot,,"comm.drv=comm.drv"
system.ini, boot, "~CommDrvTemp~=*","comm.drv=*", 3
纵是千年万年 亦难以忘记
Floor 6 Posted 2006-12-29 03:16 ·  中国 广东 河源 电信
中级用户
★★
Credits 266
Posts 98
Joined 2006-04-21 20:29
20-year member
UID 54223
Gender Male
Status Offline
Installation Information File (.inf) Definition

Update .ini Fields Section (UpdateIniFields)
[ update-inifields-section-name ]
ini-file, ini-section, profile-name, [old-field], [new-field],[flags]
.
.
In the given .ini item's value, replace, add, and delete fields. Unlike the Update .ini File section type, this section type replaces, adds, or deletes part of the values in the .inf file entry, not all values. The section name update-inifields-section-name must appear in the UpdateIniFields item of the Install section in the .inf file. For details on specifying the .ini file name, refer to the topic describing the Update .ini File section type.

ini-section
The section name of the .ini file containing the entry to be changed.

profile-name
The name of the entry to be changed.

old-field
The "field" value to be deleted.

new-field
The field value to be added that was not originally present.

flags
Specify whether to handle the old-field and new-field parameters, such as whether wildcards can be used or the delimiter to use when adding a new field to the end of the .inf file. Can be any of the following values:

Value | Meaning
0 (default) When matching fields, the "*" character is processed literally and not treated as a wildcard. When adding a new field to an entry, a space (" ") is used as the delimiter.
1 When matching fields, the "*" character is treated as a wildcard. When adding a new field to an entry, a space (" ") is used as the delimiter.
2 When matching fields, the "*" character is processed literally and not treated as a wildcard. When adding a new field to an entry, a comma (",") is used as the delimiter.
3 When matching fields, the "*" character is treated as a wildcard. When adding a new field to an entry, a comma (",") is used as the delimiter.

Remove any comments from the .ini file line, as these fields may no longer be applicable after the change. When processing the fields of the .inf file line, use spaces, tabs, and commas as field delimiters. But when a new field is added to this line, a space will be used as the delimiter.


Return to the beginning of the file

Add Registry Section (AddReg)
[ add-registry-section]
reg-root-string, [subkey], [value-name], [flag], [value]
[reg-root-string, [subkey], [value-name], [flag], [value]]
.
.
Add a subkey or value name to the registry, optionally setting its value. The add-registry-section name must appear in the AddReg entry of the Install section.

reg-root-string
The registry root name. Can be one of the following values:

HKCR is the same as HKEY_CLASSES_ROOT
HKCU is the same as HKEY_CURRENT_USER
HKLM is the same as HKEY_LOCAL_MACHINE
HKU is the same as HKEY_USERS.
HKR means related to the key value passed to GenInstallEx.

subkey
Optional. Identifies the subkey to be set. The form key1 can represent this parameter as a replaceable string. For example, %Subkey1% can be used, and the string to replace %Subkey1% is defined in the Strings section of the .inf file.

value-name
Optional. Identifies the value name of the subkey. For string types, if the value-name parameter is empty, the subkey value specified in the subkey parameter will be set to the NULL string. Note that the value-name parameter can be represented as a replaceable string. For example, %Valname1% can be used, and the string to replace %Valname1% is defined in the Strings section of the .inf file.

flag
Optional. Determines the type of value and whether the registry entry needs to be replaced if it already exists.

Value | Meaning
0 (default) The value is an ANSI string. If it exists, the registry entry is replaced.
1 The value is a hexadecimal number. If it exists, the registry entry is replaced.
2 The value is an ANSI string. If it exists, the registry main entry is not replaced.
3 The value is a hexadecimal number. If it exists, the registry main entry is not replaced.

value-name
Optional. Sets the value. It can be an ANSI string, a hexadecimal symbol, or a number in Intel format. Any item containing a binary value can be extended with the backslash (\) symbol. A string main item in the form %strkey% can also be given. strkey must be defined in the Strings section of the .inf file. To use the character % in this line, use %%.

At least two fields are required; but one can be empty. So at least one comma is needed when using this form.

In the following example of an AddReg-type section, there are two items that add two value names to the registry. Note that %25% will expand to the Windows folder of the computer.

[MyAppRegEntries]
HKLM,Software\MyApp,ProgramName,,"My Application"
HKLM,Software\MyApp,"rogram Location",,"%25%\MyApp.exe"

Return to the beginning of the file

Delete Registry Section (DelReg)
[ del-registry-section]
reg-root-string, subkey, [value-name]
[reg-root-string, subkey, [value-name]]
.
.
Delete a subkey or value name from the registry. The del-registry-section name must appear in the DelReg entry of the Install section.

reg-root-string
The registry root name. Can be one of the following values:

HKCR is the same as HKEY_CLASSES_ROOT
HKCU is the same as HKEY_CURRENT_USER
HKLM is the same as HKEY_LOCAL_MACHINE
HKU is the same as HKEY_USERS.
HKR means related to the key value passed to GenInstallEx.

subkey
Identifies the subkey to be deleted. The form is key1\key2\key3... This parameter can be represented as a replaceable string. For example, %Subkey1% can be used, and the string to replace %Subkey1% is defined in the Strings section of the .inf file.

value-name
Optional. Identifies the value name of the subkey. Note that the value-name parameter can be represented as a replaceable string. For example, %Valname1% can be used, and the string to replace %Valname1% is defined in the Strings section of the .inf file.

This section type can contain any number of items. Each item deletes a subkey or value name from the registry.

Ini File to Registry Section (Ini2Reg)
[ ini-to-registry-section]
ini-file, ini-section, [ini-key], reg-root-string, subkey[,flags]
.
.
Move lines and sections from the .ini file to the registry, creating or replacing registry entries under the given main key in the registry. The section name ini-to-registry-section must appear in the Ini2Reg entry of the Install section in the .inf file.

ini-file
The name of the .ini file containing the registry entries to be copied. For details on specifying the .ini file name, refer to the reference topic on the Update .ini File section.

ini-section
The section name in the .inf file containing the registry entries to be copied.

ini-key
The name of the registry entry in the .inf file to be copied to the registry. If ini-key is empty, the entire section is converted to the specified registry entry.

reg-root-string
The registry root name. Can be one of the following values:

HKCR is the same as HKEY_CLASSES_ROOT
HKCU is the same as HKEY_CURRENT_USER
HKLM is the same as HKEY_LOCAL_MACHINE
HKU is the same as HKEY_USERS.
HKR means related to the key value passed to GenInstallEx.

subkey
Identifies the subkey that will receive this value. The form is key1\key2\key3...

flags
Indicates whether to delete the .ini main entry after converting to the registry, and whether to overwrite the value in the registry if the registry main entry already exists. Can be one of the following values:

Value | Meaning
0 (default) After moving the information in the entry to the registry, the .ini entry is not deleted from the .ini file. If the registry subkey already exists, the current value is not replaced.
1 After moving the information in the entry to the registry, the .ini entry is deleted from the .ini file. If the registry subkey already exists, the current value is not replaced.
2 After moving the information in the entry to the registry, the .ini entry is not deleted from the .ini file. If the registry subkey already exists, the current value is replaced with the value of the .ini file entry.
3 After moving the information in the entry to the registry, the .ini entry is deleted from the .ini file. If the registry subkey already exists, the current value is replaced with the value of the .ini file entry.
For example, assume the following entry exists in the Win.ini file: [Windows]
CursorBlinkRate=15
If the CursorBlinkRate subkey does not exist under Control Panel\Desktop, then the following item in the Ini File to Registry section will create the subkey and set its value to 15, and the original line in WIN..ini will not be changed:

win.ini,Windows,CursorBlinkRate,HKCU,"Control Panel\Desktop"
If the registry subkey already exists, the .inf file item will set the value of the registry subkey to 15, and the original line in WIN..ini will not be changed.

Update Config.sys Section (UpdateCfgSys)
[update-config-section]
Buffers=legal-dos-buffer-value
DelKey=key
DevAddDev=driver-name,configkeyword[,flag][,param-string]
DevDelete=device-driver-name
DevRename=current-dev-name,new-dev-name
Files=legal-dos-files-value
PrefixPath=ldid[,ldid]
RemKey=key
Stacks=dos-stacks-values


Provide commands to add, delete, or rename commands in the Config.sys file. The section name update-config-section-name must appear in the UpdateConfigSys entry of the Install section in the .inf file.

Not all item types in the syntax listed above are required. The Update Config.sys section can include DevRename, DevDelete, DevAddDev, DelKey, and RemKey as needed, but the items Buffers, Files, and Stacks can only be used once in a section. When processing the Update Config.sys section, the installer will process all DevRenames items first, then all DevDelete items, and finally all DevAddDev items. The syntax and meaning of each item that can be used in the Update Config.sys section will be in the topics shown later.

Buffers Item

Buffers=legal-dos-buffer-value
Set the number of file buffers. Like the Stacks item, the installer compares the existing value with the suggested value, then sets the file buffers to the larger of the two.

legal-dos-buffers-value
A valid MS-DOS buffer value.

DelKey Item

DelKey=key
Comment out the Config.sys command with the specified main item in the Config.sys file. For example, in the following .inf file item:

DelKey=Break
Comment out the Break=on command in the Config.sys file.

The DelKey item has the same effect as the RemKey item. There can be multiple DelKey and/or RemKey items in the section of the .inf file.

key
Comment out the main item of the Config.sys command.

DevAddDev Item

DevAddDev=driver-name,configkeyword[,flag][,param-string]
Add a device or install command to the CONFIG.SYS file.

driver-name
The name of the driver or executable file to be added. The installer will verify the file extension to ensure it is .sys or .exe.

configkeyword
The command name. Can be device or installer.

flag
Optional position flag. If it is 0, the command is placed at the end of the file. If it is 1, it is placed at the top. If no flag is given, it defaults to 0.

param-string
Optional command parameters. Must be valid for the given device driver or executable file.

DevDelete Item

DevDelete=device-driver-name
Delete any line containing the specified file name from the Config.sys file.

device-driver-name
The file name or device driver name. The installer searches for this name in the Config.sys file and deletes any command line containing this name. Since MS-DOS does not allow omitting the file extension in the Config.sys file, each device-driver-name must explicitly specify the file extension.

In the following example, the following DevDelete item in the Update Config.sys section will delete line 1 and line 3 of the command, but not line 2 of the Config.sys sample file:

DevDelete=filename.sys
;; lines in Config.sys
Device=Filename.sys ;; line #1
Install=Filename.exe ;; line #2
Device=Filename.sys /d:b800 /I:3 ;; line #3
DevRename Item

DevRename=current-dev-name,new-dev-name
Rename a device driver in the Config.sys file.

current-dev-name
The name of the device driver or executable file to be changed. The installer will look for the name on the right side of the device or install command in the Config.sys file.

new-dev-name
The new name of the driver or executable file.

Files Item

Files=legal-dos-files-value
Set the maximum number of open files in the Config.sys file. Like the Stacks item, the installer compares the existing value with the suggested value, then sets the maximum number of open files to the larger of the two.

legal-dos-files-value
A valid MS-DOS file value.

PrefixPath Item

PrefixPath=ldid[,ldid]
Append the path related to the given LDID to the path command.

ldid
Can be any predefined LDID value or a new value defined in the .inf file. For the definition of all predefined LDID values, refer to the "Reference" topic of the DestinationDirs section.

RemKey Item

RemKey=key
Can comment out the Config.sys command with the specified main item in the Config.sys file. For example, in the following .inf file item:

RemKey=Break
Comment out the Break=on command in the Config.sys file.

The RemKey item has the same effect as the DelKey item. There can be multiple RemKey and/or DelKey items in the section of the .inf file.

key
Comment out the main item of the Config.sys command.

Stacks Item

Stacks=dos-stacks-values
Set the number and size of stacks in the Config.sys file. The installer will compare the existing value with the suggested value, then set the stacks to the larger of the two. For example, if the Config.sys file contains stacks=9,218 and the .inf file contains stacks=5,256, then the installer will set the new value to stacks=9,256.

legal-dos-stacks-value
A valid MS-DOS stack value
纵是千年万年 亦难以忘记
Floor 7 Posted 2006-12-29 03:17 ·  中国 广东 河源 电信
中级用户
★★
Credits 266
Posts 98
Joined 2006-04-21 20:29
20-year member
UID 54223
Gender Male
Status Offline
### Installation Information File (.inf) Definition

#### Update Autoexec.bat Section (UpdateAutoBat)
[update-autoexec-section]
CmdAdd=command-name[,command-parameters]
CmdDelete=command-name
PrefixPath=ldid[,ldid]
RemOldPath=ldid[,ldid]
TmpDir=ldid[,subdir]
UnSet=env-var-name

Provide commands to handle command lines in the Autoexec.bat file. The section name update-ini-section-name must appear in the UpdateInis entry of the Install section in the .inf file.

The Update Autoexec.bat section does not need all item types in the above syntax. The section can include CmdAdd, CmdDelete, and UnSet items as needed, but the PrefixPath, RemOldPath, and TmpDir items can only be used once in the .inf file. The syntax and meaning of each item type will be introduced later in this topic.

The installer processes all CmdDelete items before any CmdAdd items.

**CmdAdd Item**

CmdAdd =command-name[,"command-parameters"]
Add the given command and optional command parameters to the end of the Autoexec.bat file.

- command-name: Name of the executable file, which can have an extension or not. If the file name is also defined in the SourceDisksFiles and DestinationDirs sections of the .inf file, the installer will add the correct path to the file name before writing it to the Autoexec.bat file.
- command-parameters: A string enclosed in double quotes or a replaceable string like %String1% or %Myparam%. The string to replace %String1% and %Myparam% should be defined in the Strings section of the .inf file. The installer appends the string to command-name before appending the line to the end of the Autoexec.bat file. The format of the line depends on the command-line requirements of the given executable file.

**CmdDelete Item**

CmdDelete=command-name
Delete any command line in the Autoexec.bat file that includes the given command name. The installer will search for files with .exe, .com, and .bat extensions with the given name and delete the found files.

- command-name: Executable file name without an extension.

**PrefixPath Item**

PrefixPath=ldid[,ldid]...
Append the path related to the given LDID to the path command.

- ldid: Can be any predefined LDID value or a new value defined in the .inf file. For definitions of all predefined LDID values, refer to the "Reference" topic of the DestinationDirs section.

**RemOldPath Item**

RemOldPath=ldid[,ldid]
Remove the path related to the given LDID from the command path. For example, if the user installs a new version of Windows to C:\Newwin and has an old version in C:\Windows, the following .inf file entry will remove C:\Windows from the path environment variable:

RemOldPath=10
- ldid: Can be any predefined LDID value and a new value defined in the .inf file. For definitions of all predefined LDID values, refer to the "Reference" topic of the DestinationDirs section.

**TmpDir Item**

TmpDir=ldid[,subdir]
Create a temporary folder in the folder given by LDID if it does not exist.

- ldid: Can be any predefined LDID value or a new value defined in the .inf file. For definitions of all predefined LDID values, refer to the "Reference" topic of the DestinationDirs section.
- subdir: Path name. If ldid\subdir does not exist, create it.

**UnSet Item**

UnSet=env-var-name
Delete any set command in the Autoexec.bat file that includes the given environment variable name.

- env-var-name: Environment variable name.


**Back to the beginning of the file**

#### DestinationDirs Section
[DestinationDirs]
file-list-section =ldid[, subdir ]
.
.
[DefaultDestDir=ldid[, subdir ]]

The DestinationDirs section defines the target directory for the operations specified in the file-list section (which can be CopyFiles, RenFiles, or DelFiles sections). Additionally, the default target folder can be specified in any CopyFiles, RenFiles, or DelFiles section in the .inf file without explicitly naming it in the DestinationDirs section.

- file-list-section: Name of the CopyFiles, RenFiles, or DelFiles section. Must be referenced in the Copyfiles, RenFiles, or DelFiles entry of the Install section.
- ldid: Logical disk identifier (LDID). Can be one of the following values:

- 00 Null LDID - Can be used to create a new LDID
- 01 Source drive:\pathname
- 10 Machine folder (maps the Windows folder during a server-based installation.
- 11 System folder
- 12 IOSubsys folder
- 13 Command folder
- 17 Inffolder
- 18 Help folder
- 20 Fonts
- 21 Viewers
- 22 VMM32
- 23 Color folder
- 24 Root folder containing the Windows folder
- 25 Windows folder
- 26 Conventional boot device for Windows (Winboot)
- 28 Host Winboot
- 30 Root folder of the boot disk
- 31 Root folder of the primary drive of the virtual boot disk

- subdir: Subfolder name in the folder named by LDID that will be the target subfolder.

The optional DefaultDestDir item provides the default target directory for any CopyFiles item, which can use the direct copy (@file name) symbol or any CopyFiles, RenFiles, or DelFiles section not specified in the DestinationDirs section. If DefaultDestDir is not used in the DestinationDirs section, the default folder is set to LDID_WIN.

The following example sets the target folder of the MoveMiniPort section to Windows\Ilsybsys and the default folder of other sections to the Bin folder on the boot disk:

[DestinationDirs]
MoveMiniPort=12 ; Target folder of the MoveMiniPort section is
; windows\iosubsys
DefaultDestDirs=30, bin ; Copy to boot:\bin

**Back to the beginning of the file**

#### SourceDisksNames Section
[SourceDisksNames]
disk-ordinal="disk-description",disk-label,disk-serial-number
.
.
Identify and name the disks containing the source files for file copy and rename operations.

- disk-ordinal: Unique number identifying the source disk. If there are multiple source disks, each must have a unique ordinal.
- disk-description: String or string main item describing the contents or purpose of the disk. The installer displays this string to the user to identify the disk. This description is enclosed in double quotes.
- disk-label: Source disk volume label set when formatting the source disk.
- disk-serial-number: Not used. Then the value must be 0.

The following example identifies a source disk. The disk description is given by the string main item:

[SourceDisksNames]
55 = %ID1%, Instd1, 0[Strings]
ID1="My Application Installation Disk 1"

**Back to the beginning of the file**

#### SourceDisksFiles Section
[SourceDisksFiles]
file name=disk-number[,subdir] [,file-size]
.
.
color=#000000 Name the source files used during the installation process and identify the source disk containing the file.

- filename: Filename on the source disk.
- disk-number: Ordinal number of the source disk containing the file. The ordinal must be defined in the SourceDisksNames section and must be a value greater than or equal to 1 (0 is an invalid disk number parameter value).
- subdir: Optional parameter specifying the subfolder on the source disk where the file is located. If this parameter is not used, the default is the root folder on the source disk.
- file-size: Optional parameter specifying the file size in bytes.

The following SourceDisksFiles section example identifies a single source file SRS01.386 on a disk with serial number 1:

[SourceDisksFiles]
SRS01.386 = 1

**Back to the beginning of the file**

#### Strings Section
[Strings]
strings-key=value
.
.
Define one or more string main items. A string main item is a name represented by a printable string. Although the Strings section is usually the last section of the .inf file, the string main items defined in this section can be used anywhere in the .inf file where the corresponding string is used. The installer expands the string main item to the given string and uses it for further processing. The string main item must be enclosed in percent signs (%).

- strings-key: Unique name composed of characters and numbers.
- value: String composed of letters, numbers, or other printable characters. If the corresponding string main item that needs double quotes is used in the item type, it should be enclosed in double quotes.

The Strings section makes it very easy to translate strings for international markets. You only need to place all strings that can be displayed in the user interface in a separate section of the .inf file. String main items should be used whenever possible.

The following example shows the Strings section of an .inf example file.

[Strings]
String0="My Application"
String1="My Application Readme File"
String2="CX2590 SCSI Adapter"

**Back to the beginning of the file**

#### Optional Components Section
[Optional Components]
install-section-name
[install-section-name]
.
.
List the Install sections that are displayed when the user clicks the "Add/Remove Programs" icon on the "Control Panel", clicks the "Install Windows" tab, and then clicks the "Install from disk" button. The Install sections will be displayed as checkboxes in the list.

Note that the Optional Components section is ignored when the .inf file is executed by right-clicking the .inf file and selecting the "Install" command. When the .inf file is executed in this way, the [DefaultInstall] section is executed. The Optional Components section is also ignored when the .inf file is executed through the Setupx.dll InstallHinfSection entry point. When the .inf file is executed through the SETUPX entry, the Install section specified in the entry parameter is executed.

The Install section has the same format as introduced before. The following main items can be added to the Install section to start the interface in the "Install from disk" dialog:

- OptionDesc=option-description
- Tip=tip-description
- InstallDefault=0 | 1 ; Whether to install this component by default. 1=Yes, 0=No.
- IconIndex=icon-index
- Parent=install-section-name
- Needs=install-section-name, [install-section-name]
- Include=inf-file, [inf-file]

- option-description: String value used as the component name in the list box. The option-description parameter can be %String1%, and the string to replace %String1% is defined in the Strings section of the .inf file.
- tip-description: String value displayed in the "Description" box when the component is selected in the list box. The tip-description parameter can be up to 255 characters and can be %String1%, and the string to replace %String1% is defined in the Strings section of the .inf file.
- icon-index: Value determining the small icon displayed next to the component name. Valid values are: 0 Machine (basic and display)
1 Integrated circuit chip
2 Monitor
3 Network cable
4 Windows logo
5 Mouse
6 Keyboard (3 keys)
7 Microphone
8 Speaker
9 Hard disk
10 Serial port connector
11 Diamond frame (default)
12 Checkbox
13 Unchecked checkbox
14 Printer
15 Network card
16 Icon shaped like 0
17 Similar to 0 shape, with a shared hand shape below
18 Unknown (question mark)
19 Working icon
20 Grayed checkbox
21 Dial-up networking
22 Direct cable connection
23 Briefcase
24 Exchange
25 Partially selected
26 Accessories group
27 Multimedia group
28 Quick view
29 MSN
30 Calculator
31 Disk defragmenter
32 General document
33 Disk defragmenter
34 Solitaire
35 HyperTerminal
36 Object package
37 Paint
38 Screen saver
39 WordPad
40 Clipboard viewer
41 Accessibility options
42 Backup
43 Bitmap document
44 Character map
45 Mouse pointer
46 Network monitor
47 Phone dialer
48 System monitor
49 Help manual
50 Earth (locale)
51 Audio compression
52 CD player
53 Media player
54 Sound scheme
55 Video clip
56 Video compression
57 Volume control
58 "Musical" sound scheme
59 "Frog" sound scheme
60 "Metallic" sound scheme
61 "Fantasy Space" sound scheme

- Parent: The list box displayed in the optional components interface can contain sub-layers. If the optional component is a sub-component, Parent= keyword defines the Install section of the parent component.
- Needs: If the component is subordinate to other components, this defines the Install section that the component needs. If this component is selected, the system will warn the user that this component needs the component described in the Install section listed in the Needs= line.

Note that the Install sections listed in the Needs= line must be in the same .inf file. However, if the subordinate component of another .inf file is listed in the Needs= line, the .inf file must be specified in the Include= line.
- Include: The Include item allows you to specify the .inf file, and the installer must also load the .inf file into memory when loading the .inf file because these .inf files contain sections that must be run in addition to the Install section in the .inf file. The Needs item specifies the section name to be run in the included .inf file.

The following example defines two optional component installation sections, each using other entries to specify interface elements and subordination:

[Optional Components]
InstallMyToys
InstallGames[InstallMyToys]
OptionDesc=%Toys_DESC%
Tip=%Tomytoysys_TIP%
IconIndex=35 hone mini-icon for dialogs
Parent=MailApps
Needs=MSMAIL, MAPI, MicrosoftNetwork
Include=mos.inf, msmail.inf
CopyFiles=MyToysFiles
UpdateInis=MyToysLinks
AddReg=MyToysRegItems[InstallOtherApps]
OptionDesc=%Other_DESC%
Tip=%Other_TIP%
IconIndex=4 ; windows mini icon for dialogs
CopyFiles=OtherFiles
UpdateInis=OtherLinks
AddReg=OtherRegItems[Strings]
Toys_DESC="Mail Utilities"
Toys_TIP="Additional utilities for sending and organizing mail"
Other_DESC="Other Helpful Utilities"
Other_TIP="Calculator, disk checker and performance monitor"
纵是千年万年 亦难以忘记
Floor 8 Posted 2006-12-29 03:22 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Floor 9 Posted 2006-12-29 03:31 ·  中国 湖北 武汉 电信
初级用户
Credits 40
Posts 14
Joined 2006-12-27 11:38
19-year member
UID 74713
Gender Male
Status Offline
Why can I only add 2 points
Floor 10 Posted 2006-12-29 03:35 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Originally posted by rochan at 2006-12-28 14:31:
Why can I only add 2 points


  Because your level is relatively low, and the forum gives different scoring permissions for different levels.
Floor 11 Posted 2007-01-27 08:37 ·  中国 江西 吉安 遂川县 电信
中级用户
★★
Credits 253
Posts 112
Joined 2006-05-31 11:12
20-year member
UID 56308
Gender Male
Status Offline
Haha, although it's a bit long, it's worth me spending a long time to study!
Floor 12 Posted 2007-01-27 09:15 ·  中国 广东 广州 珠江宽频
中级用户
★★
Credits 210
Posts 85
Joined 2007-01-14 12:38
19-year member
UID 76501
Gender Male
From 广东广州
Status Offline
Good article, worthy of collection, thanks to the LZ!
Floor 13 Posted 2007-01-27 09:34 ·  美国 弗吉尼亚州 梅克伦堡县 博伊顿 Microsoft
高级用户
★★
Credits 783
Posts 268
Joined 2006-12-26 17:18
19-year member
UID 74627
Gender Male
Status Offline
Just searching online and suddenly found it in the forum. Ecstatic! Bump!
菩提本无树,明镜亦非台,本来无一物,何处惹尘埃.
Floor 14 Posted 2008-05-10 01:55 ·  中国 辽宁 锦州 联通
中级用户
★★
Credits 228
Posts 106
Joined 2008-04-26 12:34
18-year member
UID 117003
Gender Male
Status Offline
Well, it's valuable. Thanks to the poster!
Floor 15 Posted 2008-05-10 12:06 ·  中国 江苏 南京 电信
初级用户
Credits 94
Posts 46
Joined 2006-05-14 01:59
20-year member
UID 55490
Gender Male
Status Offline
It would be nice to make it into an e-book, but it's already very good now. I've been researching this thing these past few days.
Forum Jump: