[Version]节
[Version] Signature="signature-name" Class=class-name ClassGUID=GUID Provider=INF-creator LayoutFile=filename.inf[,filename.inf]... |
signature-name
可以是 $Windows NT$, $Chicago$, or $Windows 95$ 中任意一种。如果不是三者之一,该INF不能被 Windows NT识别。签名字符串是大小写敏感的。
class-name
定义该INF文件安装的设备所对应的注册表中的类名。
GUID
可选项。定义设备的GUID值。Windows NT定义的GUID如下:
Adapter | 4d36e964L-e325-11ce-bfc1-08002be10318 |
CD-ROM | 4d36e965L-e325-11ce-bfc1-08002be10318 |
Computer | 4d36e966L-e325-11ce-bfc1-08002be10318 |
Disk Drive | 4d36e967L-e325-11ce-bfc1-08002be10318 |
Display | 4d36e968L-e325-11ce-bfc1-08002be10318 |
FDC | 4d36e969L-e325-11ce-bfc1-08002be10318 |
HDC | 4d36e96aL-e325-11ce-bfc1-08002be10318 |
Keyboard | 4d36e96bL-e325-11ce-bfc1-08002be10318 |
Media | 4d36e96cL-e325-11ce-bfc1-08002be10318 |
Modem | 4d36e96dL-e325-11ce-bfc1-08002be10318 |
Monitor | 4d36e96eL-e325-11ce-bfc1-08002be10318 |
Mouse | 4d36e96fL-e325-11ce-bfc1-08002be10318 |
MTD | 4d36e970L-e325-11ce-bfc1-08002be10318 |
Multifunction | 4d36e971L-e325-11ce-bfc1-08002be10318 |
Network | 4d36e972L-e325-11ce-bfc1-08002be10318 |
Network Client | 4d36e973L-e325-11ce-bfc1-08002be10318 |
Network Service | 4d36e974L-e325-11ce-bfc1-08002be10318 |
Network Transport | 4d36e975L-e325-11ce-bfc1-08002be10318 |
No Driver | 4d36e976L-e325-11ce-bfc1-08002be10318 |
PCMCIA | 4d36e977L-e325-11ce-bfc1-08002be10318 |
Ports | 4d36e978L-e325-11ce-bfc1-08002be10318 |
Printer | 4d36e979L-e325-11ce-bfc1-08002be10318 |
Printer Upgrade | 4d36e97aL-e325-11ce-bfc1-08002be10318 |
SCSI Adapter | 4d36e97bL-e325-11ce-bfc1-08002be10318 |
Sound | 4d36e97cL-e325-11ce-bfc1-08002be10318 |
System | 4d36e97dL-e325-11ce-bfc1-08002be10318 |
Tape Drive | 6d807884L-7d21-11cf-801c-08002be10318 |
Unknown | 4d36e97eL-e325-11ce-bfc1-08002be10318 |
INF-creator
标记该INF文件的创建人,一般地,这是创建该INF文件的组织(团体、公司)名称。
filename.inf
INF文件包含的安装驱动程序软件所需的layout(布局)信息——源盘和文件。如果filename.inf 没有指定,SourceDisksNames 和 SourceDisksFiles 节名必需包含在该INF文件中。
下列例子展示了典型的 Version 节:
[Version]
Signature="$Windows NT$"
Class=Mouse
ClassGUID={4D36E96F-E325-11CE-BFC1-08002BE10318}
Provider=%Provider%
LayoutFile=layout.inf
[Strings]
Provider="Corporation X"
[DestinationDirs]
节
[DestinationDirs]节指定拷贝、重命名或删除文件(Copy Files, Rename Files, Delete Files)三类动作的目的目录路径,拷贝、重命名或删除操作对象即文件的列表在专门的节中列出,这些节名最初在“Install”的CopyFiles、RenFiles或DelFiles入口中明确。
语法:
file-list-section=drid[,subdir] . . . [DefaultDestDir=drid[,subdir]] |
解释:
file-list-section
必选项,Copy Files, Rename Files,或者Delete Files节的名称,参见[Install]节的说明。
Drid
目录标识符,可以为下列数值:
Drid |
说明 |
-01 |
Absolute path (32-bit) |
0xffff |
Absolute path (16-bit). |
01 |
SourceDrive:\pathname. The directory from which the INF file was installed. |
10 |
Windows directory |
11 |
System directory. This is %windir%\system32 on Windows NT and %windir%\system on Windows 95. |
12 |
Drivers directory. This is %windir%\system32\drivers on Windows NT |
17 |
INF file directory. |
18 |
Help directory. |
20 |
Fonts directory. |
21 |
Viewers directory. |
24 |
Applications directory. |
25 |
Shared directory. |
30 |
Root directory of the boot drive. |
50 |
%windir%\system directory. |
51 |
Spool directory. |
53 |
User Profile directory. |
54 |
Directory where ntldr.exe and osloader.exe are located. |
Subdir
为可选项。指定LDID目录下的子目录名,指定最终的目标目录。
[DestinationDirs]
为可选项。用以指定上述[DestinationDirs]节中未指定的目录,作为CopyFiles、RenFiles或DelFiles入口的缺省操作目录。如果没有使用DefaultDestDir项,缺省目录设置为drid_system。
举例
下列示例将INF文件中所有节的缺省目录设置为drivers目录:
[DestinationDirs]
DefaultDestDir = 12
CopyFiles节指定了从源盘拷贝到目标目录的所有文件清单。源盘和目标目录的每个文件与INF文件中的其它节中指定的文件相关联。file-list-section名称应该出现在一个Install 节的CopyFiles 项下。
你可以使用Install 节的CopyFiles项拷贝一个单独的文件,无需构造CopyFiles节。
[file-list-section] destination-file-name[,source-file-name][,temporary-file-name][,flag] [destination-file-name[,source-file-name][,temporary-file-name]][,flag] . . .
|
destination-file-name
目标文件名称。如果没有源文件名称被指定,它也就是源文件。
source-file-name
源文件名。如果这个源文件与目标文件同名,则此源文件source-file-name 可省略。
temporary-file-name
拷贝操作时用的临时文件名。安装程序拷贝源文件,但指定为一个临时文件名。在下次操作系统启动后,将修改这个临时文件名到目标文件名。临时文件可以用来覆盖当前已经打开或者在用的目标文件。这个参数没有被立即知性。如果需要,SETUP函数自动产生临时文件。
flag
可选项。这个标志用来控制文件如何被拷贝。其数值可以是10进制,或者以0X开头的16进制数值。
COPYFLG_WARN_IF_SKIP |
0x00000001 |
Send a warning if the user elects to not copy a file. |
COPYFLG_NOSKIP |
0x00000002 |
Do not allow the user to skip copying a file. |
COPYFLG_NOVERSIONCHECK |
0x00000004 |
Ignore file versions and write over existing files in the destination directory. |
COPYFLG_FORCE_FILE_IN_US E |
0x00000008 |
Force file-in-use behavior. |
COPYFLG_NO_OVERWRITE |
0x00000010 |
Do not write over an existing file in the destination directory with a source file. |
COPYFLG_NO_VERSION_DIALOG |
0x00000020 |
Do not write over a file in the destination directory with the source file if the existing file is newer than the source file. |
COPYFLG_REPLACEONLY |
0x00000040 |
Copy the source file to the destination directory only if the file is already present in the destination directory. |
下列示例拷贝2个文件:
[CopyTheseFilesSec]
file11 ; copies file11
file31, file32 ; copies file32 to file31
示例中,所有源文件应该在[SourceDisksFiles]节中指定,其目录标示应该出现在[SourceDisksFiles]节中指定。作为一种选择,你也可以使用一个layout.inf 文件来支持这个信息。
The Add Registry section adds subkeys or value names to the registry, optionally setting the value. The add-registry-section name must appear in an AddReg item in an Install section.
[add-registry-section]
reg-root-string
, [subkey], [value-name], [flags], [value]
[reg-root-string, [subkey], [value-name], [flags], [value]]
.
.
.
reg-root-string
注册表根root名。可以是缩写,列表如下:
注册表根字符串 |
注册表根 |
HKCR |
HKEY_CLASSES_ROOT. |
HKCU |
HKEY_CURRENT_USER. |
HKLM |
HKEY_LOCAL_MACHINE. |
HKU |
HKEY_USERS. |
HKR |
Relative to the key passed into SetupInstallFromInfSection. |
subkey
可选项。用来标记被设置的子项,可以是key1\key2\key3....
value-name
可选项。标记子项的数值。对于字符串类型,如果value-name 参数为左空,则这个子项使用缺省数值。
flag
可选项。
Establishes the value data type and the AddReg item action. The flag value is a bit map where the low word contains basic flags that define the general data type and AddReg item action. The high word contains values that more specifically identify the data type of the registry value. The high word is ignored by the 16-bit Windows 95 Setup functions provided by the Setupx DLL. The flags are defined as follows:
FLG_ADDREG_BINVALUETYPE |
(0x00000001) |
The value is "raw" data. |
FLG_ADDREG_NOCLOBBER |
(0x00000002) |
Do not write over the registry key if it already exists. |
FLG_ADDREG_DELVAL |
(0x00000004) |
Delete the value from the registry. |
FLG_ADDREG_APPEND |
(0x00000008) |
Append a value to an existing value. This flag is currently supported only for REG_MULTI_SZ values. |
FLG_ADDREG_TYPE_MASK |
(0xFFFF0000 | FLG_ADDREG_BINVALUETYPE) |
Mask. |
FLG_ADDREG_TYPE_SZ |
(0x00000000) |
Registry data type REG_SZ. |
FLG_ADDREG_TYPE_MULTI_SZ |
(0x00010000) |
Registry data type REG_MULTI_SZ. |
FLG_ADDREG_TYPE_EXPAND_SZ |
(0x00020000) |
Registry data type REG_EXPAND_SZ. |
FLG_ADDREG_TYPE_BINARY |
(0x00000000 | FLG_ADDREG_BINVALUETYPE) |
Registry data type REG_BINARY. |
FLG_ADDREG_TYPE_DWORD |
(0x00010000 | FLG_ADDREG_BINVALUETYPE) |
Registry data type REG_DWORD. |
FLG_ADDREG_TYPE_NONE |
(0x00020000 | FLG_ADDREG_BINVALUETYPE) |
Registry data type REG_NONE. |
Bit 0 of the flag distinguishes between character and binary data as it does in the Windows 95 Setup functions, thus a Windows 95 installation program will see the extended data types as REG_SZ or REG_BINARY. To allow REG_DWORD entries to be compatible with both operating systems, the following formats are supported:
· Non-compatible format. If compatibility with Windows 95 Setup functions is not required, a REG_DWORD entry can contain a single data value field. This value can be prefixed with a sign and be either decimal or hexadecimal. For example:
HKLM,"Software\Microsoft\Windows NT\CurrentVersion\FontDPI","LogPixels",0x10001,120
· Windows 95 compatible format. If compatibility with Windows 95 Setup functions is required, the data of a FLG_ADDREG_TYPE_DWORD entry must be formatted like a REG_BINARY entry. The Windows NT Setup functions recognize a REG_DWORD line with exactly four data elements as conforming to this format. The Setup functions interpret the four data elements as one DWORD. Hexadecimal number fields are only supported by the Windows 95 Setup functions as members of a REG_BINARY data list, in which case the data is assumed to be in hexadecimal format (the 0x prefix must not be used). The example listed above can be written in Windows 95-compatible format as follows:
HKLM,"Software\Microsoft\Windows NT\CurrentVersion\FontDPI","LogPixels", 65537,78,0,0,0
To represent a number with a data type other than the predefined REG_* types, you can specify the type number in the flag's high word and specify binary type in its low word. You must enter the data in binary format, one byte per field. For example, to store 16 bytes of data with a new data type of 0x38, you would have an AddReg item as follows:
HKR,,MYValue,0x00380001,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
This technique may be used with any data type except REG_EXPAND_SZ, REG_MULTI_SZ, REG_NONE, and REG_SZ.
value
可选项。设置的值。可以是一个字符串或者是一个16进制数。至少需要两个字段,其中一个可以是空的。此时,需要最后跟一个逗号。
示例
The two items in the example Add Registry section below, which is named sermouse_EventLog_AddReg, add two value names to the registry, EventMessageFile and TypesSupported, and set the value of these names.
[sermouse_EventLog_AddReg]
HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\sermouse.sys"
HKR,,TypesSupported,0x00010001,7
HW节是Install节一个特例。它只是一种INF文件类型,可以增减注册表入口的Enum分支。HW节用来从注册表中添加或者删除设备相关、驱动程序无关的信息。
[install-section-name.HW]
AddReg=add-registry-section[,add-registry-section]...
DelReg=del-registry-section[,del-registry-section]...
HW
节中只能出现
AddReg 和 DelReg项。使用AddReg项到HKR,可以添加信息到注册表的ENUM分支中对应的项,使用DllReg项到HKR,可以删除注册表的ENUM分支中对应的项。
Manufacturer节标示出使用INF文件进行安装的设备制造商,并列出了描述该设备的Device节。
[Manufacturer]
manufacturer-name | %strings-key%=device-section-name
manufacturer-name
设备制造商名称。可以是任何可打印字符的组合,但是它应该是该制造商的唯一标识。
strings-key
INF文件中[String]节中定义的字符串名称。
device-section-name
Device节名称。可以是任何可打印字符的组合,但是它应该是该INF文件的其它节中的唯一标识。
典型示例如下:
[Manufacturer]
%LogiMfg%=LogiMfg ; Logitech
Service Install节安装Services节中AddService入口所列出的服务。
[install-section-name_ServiceInstallSection] DisplayName=[name] ServiceType=type-code StartType=start-code ErrorControl=error-control-level ServiceBinary=path-to-service LoadOrderGroup=[load-order-group-name] Dependencies=+depend-on-group-name[[,depend-on-service-name]...] StartName=[driver-object-name] |
name
可选项,服务的友好名称。
type-code
指定驱动程序的类型。它可以是紧跟CreateService函数后的任何类型。参看Win32 SDK在线文档获得更多信息。
start-code
启动该驱动程序时指定,可以是下列之一:
SERVICE_BOOT_START (0x0) |
Indicates a driver started by the operating system loader. This code should only be used for drivers that are essential to loading the OS. |
SERVICE_SYSTEM_START (0x1) |
Indicates a driver started during OS initialization. |
SERVICE_AUTO_START (0x2) |
Indicates a driver started by the Service Control Manager during system startup. |
SERVICE_DEMAND_START (0x3) |
Indicates a driver started on demand by the Service Control Manager. |
SERVICE_DISABLED (0x4) |
Indicates a driver that cannot be started. |
error-control-level
指定错误控制等级:
CRITICAL (0x3) |
If the driver fails to load, fail the attempted startup. If the startup is not using the LastKnownGood control set, switch to LastKnownGood. If the startup attempt is using LastKnownGood, run a bug-check routine. |
SEVERE (0x2) |
If the startup is not using the LastKnownGood control set, switch to LastKnownGood. If the startup attempt is using LastKnownGood, continue on in case of error. |
NORMAL (0x1) |
If the driver fails to load or initialize, startup should proceed, but display a warning. |
IGNORE (0x0) |
If the driver fails to load or initialize, startup proceeds. No warning is displayed. |
path-to-service
指定服务程序的二进制文件所在路径。
load-order-group-name
可选项。Identifies the load order group of which this driver is a member. Examples of groups are: pointer, port, primary disk, and so forth. For detailed discussion of load order groups and controlling load order, see Chapter 1.
+depend-on-group-name
Optional. Specifies a load order group on which the driver depends. The driver is started only if at least one member of the specified group has been started. For detailed discussion of load order groups and controlling load order, see Chapter 1.
depend-on-service-name
Optional. Specifies a service that must be running before this driver is started.
driver-object-name
Optional. If type-code specifies a Kernel driver or a file system driver, this name is the Windows NT driver object name that the I/O Manager uses to load the device driver.
典型 Service Install 节示例如下:
[mouclass_Service_Inst]
DisplayName = %mouclass.SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 1 ; SERVICE_SYSTEM_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %\mouclass.sys
LoadOrderGroup = Pointer Class
你可以使用Services 节向机器中添加一系列服务程序。通过Services节中的DelService入口服务可以删除服务。
[install-section-name.Services]
AddService=ServiceName,flag,service-install-section-name[,event-log-install-section-name]
DelService=ServiceName
ServiceName
安装或者删除的服务程序。
flag
下列标志之一:
SPSVCINST_TAGTOFRONT (0x1) |
Move the service's tag to the front of its group order list. |
SPSVCINST_ASSOCSERVICE (0x2) |
Associate the service in this AddService item with the device being installed by this INF file. |
service-install-section-name
指向Service Install 节的名称。
event-log-install-section-name
指向 EventLog Install 节的名称
The following example shows a typical Services section:
[Ser_Inst.Services]
AddService = sermouse, 0x00000002, sermouse_Service_Inst, sermouse_EventLog_Inst
AddService = mouclass,, mouclass_Service_Inst, mouclass_EventLog_Inst
Install节标识出设备的描述和设备驱动程序所需要的安装文件操作方法和信息。Install节的名称应该与Manufacturer节中相关联的Device节一致。
[install-section-name]
LogConfig=log-config-section-name[,log-config-section-name]...
Copyfiles=file-list-section-name[,file-list-section-name]...
Renfiles=file-list-section-name[,file-list-section-name]...
Delfiles=file-list-section-name[,file-list-section-name]...
UpdateInis=update-ini-section-name[,update-ini-section-name]...
UpdateIniFields=update-inifields-section-name[,update-inifields-section-name]...
AddReg=add-registry-section-name[,add-registry-section-name]...
DelReg=del-registry-section-name[,del-registry-section-name]...
Ini2Reg=ini-to-registry-section-name[,ini-to-registry-section-name]...
不是上述所有的项类型都是Install节必需的。节名由可打印字符组成。一个项后边可以罗列多个节名,每个附加名称用逗号分隔。各个项应该与INF文件中指定的节名相关联。唯一的例外是CopyFiles项,如果只有一个文件被拷贝,该项没必要指定一个节。
你可以在CopyFiles项中使用一个特殊的标记,直接从CopyFiles行中一个单独的文件。拷贝一个单独的文件是通过带有@符号前缀的文件名实现的。使用这种标记的任何被拷贝的文件的目标目录由DefaultDestDir指定,定义在DefaultDestDir节。
通过在Install节后面添加扩展,你可以针对不同的操作系统或者平台定制不同的Install节。下列扩展是被Setup函数认可:
.win |
Windows 9x |
.nt |
Windows NT (all platforms) |
.ntx86 |
Windows NT (x86 only) |
.ntmips |
Windows NT (MIPS only) |
.ntalpha |
Windows NT (Alpha only) |
.ntppc |
Windows NT (PPC only) |
上述扩展是大小写敏感的。
下列Install节的示例包含一个单行的列表,列出了两个CopyFiles节。
[Ser_Inst]
CopyFiles=Ser_CopyFiles, mouclass_CopyFiles
[Ser_CopyFiles]
sermouse.sys
[mouclass_CopyFiles]
mouclass.sys
用户377235 2013-5-9 12:47
您好,我想请问下,我把USB摄像头驱动的inf中的类改成了视频类,但是还是无法被视频的上层应用程序识别,为什么呢?
用户1208503 2007-1-14 14:35
讲得太好了,现在做技术的有一部分人并非出于对技术发自内心的喜好,究竟做技术的终极目标是什么呢?
培养自己的修养,清静一下自己的心灵,我们想要的东西也许是我们不得不加以考虑的,然而也只有当我们我们超脱了我们过于急迫欲望的时候,得到的才会更多;我们的国家,我们的民族还需要更多的充满活力的新鲜血液,希望我们更多的刚刚走出校门并有志于在某个技术领域有所建树的年轻人,大家共勉!