文件具体格式:
[section] (节名)
entry=value[,value] (项)
说明:
INF文件是一个文本文件,由许多按层次结构排列的节组成,他们以方括号中的节名称开始,如[Version]、[Manufacturer]等,后面是所含有的各个项,如Signature、DriverVer等。
其中,“entry”标示项名称,“value”标示该想的取值。节名和项名称都不区分大小写,且对于Windows 98,其必须小于28个字符;对于Windows 2000,其长度的最大值为255个字节。
下表是INF文件中常用的节。
INF文件中常用的节
节 | 说明 |
Version | INF文件的开始(核心节必须包含) |
SourceDisksNames | 指明去的那个程序所在的磁盘或CD-ROM |
SourceDisksFiles | 指明驱动程序的文件名 |
Destination | 指明INF文件和驱动程序的目标文件 |
Manufacturer | 指明供应商及其对应Models节的名称[驱动程序才需要] |
Models | 指明Install/DDInstall节的名称、设备的硬件ID等信息[驱动程序才需要] |
Install(Windows 98) Install(Windows 2000) | 指明需复制的文件、想注册表中添加的内容等信息[入口] |
DDInstall.Services 仅适用于Windows 2000 | 指明驱动程序安装的详细信息 |
String | 指明一系列字符串 |
1Version节
Version节通常作为INF文件的开始,下表列出了其包含的各项。所有INF文件都必须含有Version节及其Signature项
Version节中的各项
项 | 说明 |
Signature | 指明驱动程序的签名,其取值为:$Windows NT$、$Windows 95$、$Chicago$,必须 |
Class | 指明驱动程序所属的类别,可选 |
ClassGuid | 指明设备类的GUID,其格式为:{nnnnnnnn-nnnn-nnnn-nnnnnnnnnnnn},系统中已经定义,可选 |
Provider | 指明该INF文件的供应商,可选 |
LayoutFile | 仅由操作系统内部提供的INF文件使用[一般只用于系统自带的INF文件。用于指定源盘和文件路径等信息],可选 |
CatalogFile | 指明数字签名文件的文件名,其扩展名为.cat,可选 |
DriverVer | 指明驱动程序的版本信息,其格式为:mm/dd/yyyy[,x.y.v.z],可选 |
注:①n代表一个16进制数 |
下面对主要的各项进行详细介绍。
①.Signature项:指明驱动程序的签名。对于Windows 98和Windows 2000下的USB设备驱动程序,该项的取值通常为“$Chicago$”。
"$CHICAGO$" 表明这个inf文件可以用于windows 95以后的所有平台上,目前来说就是win98,winme,winnt4,win2k,winxp,win2k3。
"$Windows 95$" 表明这个inf文件可以用于windows 95以后的Win9x平台上,目前来说就是win98,winme。
"$Windows NT$" 表明这个inf文件可以用于WindowsNT系列的平台上,包括winnt4,win2k,winxp,win2k3。WIN9x系列的操作系统的SetupAPI将会拒绝执行这种类型的inf文件。
②.Class和ClassGuid项:指明驱动程序所属的设备类别及其GUID,其取值情况见下表。
常用设备类别及其GUID
Class | ClassGuid | 说明 |
1394 | 6BDD1FC1-810F-11D0-BEC7-08002BE2092F | 1394主控制器 |
CDROM | 4D36E965-E325-11CE-BFC1-08002BE10318 | CD-ROM驱动器 |
DiskDrive | 4D36E967-E325-11CE-BFC1-08002BE10318 | 磁盘驱动器 |
Display | 4D36E968-E325-11CE-BFC1-08002BE10318 | 显示适配器 |
FDC | 4D36E969-E325-11CE-BFC1-08002BE10318 | 软盘驱动器 |
HDC | 4D36E96A-E325-11CE-BFC1-08002BE10318 | 硬盘控制器 |
HIDClass | 745a17a0-74d3-11d0-b6fe-00a0c90f57da | 人机接口设备 |
Keyboard | 4D36E96B-E325-11CE-BFC1-08002BE10318 | 键盘 |
Modem | 4d36e96c-e325-11ce-bfc1-08002be10318 | 调制解调器 |
Monitor | 4d36e96e-e325-11ce-bfc1-08002be10318 | 监视器 |
Mouse | 4d36e96f-e325-11ce-bfc1-08002be10318 | 鼠标 |
Net | 4d36e972-e325-11ce-bfc1-08002be10318 | 网络适配器 |
Ports | 4d36e978-e325-11ce-bfc1-08002be10318 | 端口(COM&LPT) |
Printer | 4d36e979-e325-11ce-bfc1-08002be10318 | 打印机 |
System | 4d36e97d-e325-11ce-bfc1-08002be10318 | 系统设备 |
TapeDrive | 6D807884-7D21-11CF-801C-08002BE10318 | 磁带驱动器 |
USB | 36FC9E60-C465-11CF-8056-444553540000 | USB |
③.DriverVer项:指明驱动程序的版本信息。其“mm/dd/yyyy”代表月/日/年;“x.y.v.z”代表驱动程序的版本号,它是可选的。
2.SourceDiskNames节
SourceDiskNames节指明设备驱动程序所在的磁盘或CD-ROM(如果是软件发布包则只需要描述接口),其各项的格式如下:
diskid=disk-description,disk-label,disk-serial-number (Windows 98)
diskid=disk-description[,[tagfile][,unused,path]] (Windows 2000)
其中,“disked”指出磁盘驱动器的编号,它是正整型数,通常从1开始,且不能重复;“disk-description”表示磁盘的描述信息,他通常为一个字符串。
对于Windows 98,“disk-label”指出磁盘的卷标;“disk-serial-numbe”指出磁盘的序列号。
对于Windows 2000,“tagfile”指出磁盘标签文件的文件名;“unused”保留未用;“path”指出驱动程序所在的路径;“[ ]”表示可选参数。
eg:
1="Codec4WMP Files","Code4WMP.cab",,"i386"
3.SourceDiskFiles节
SourceDiskFiles节指明设备驱动程序的文件名(软件发布包文件名),其各项格式如下:
filename=diskid[,subdir] (Windows 98)
filename=diskid[,[,subdir][,size]] (Windows 2000)
其中
“filename”指出驱动程序的文件名
“diskid”指出磁盘驱动器的编号
“subdir”指出该文件在磁盘上的路径
“size”指出该文件未经压缩时的大小,以字节为单位。
针对软件发布包可以只指定diskid即可
eg:
"Code4WMP.cab"=1
4.DestinationDirs节
DestinationDirs节指明INF文件和设备驱动程序的目标目录。
当INF文件使用CopyFiles、DelFiles、RenFiles指令时,则必须包含该节。其各项的格式如下:
DefaultDestDir=dirid[,subdir]
File-list-section=dirid[,subdir]
其中
“DefaultDestDir”是一个项名称,代表文件复制、删除、重命名操作的缺省的目标目录;“file-list-section”指出CopyFiles、DelFiles、RenFiles指令所引用的节;“dirid”指出目标目录值,见下表
“subdir”指出dirid目录下的子目录
-1至 32767及65535的数字为系统已定义的逻辑磁盘标
DestinationDirs节中的常用dirid
具体详细信息
%10% Windows C:\Windows
%11% System32 C:\Windows\system32
%12% Drivers C:\Windows\system32\drivers
%17% inf C:\Windows\inf
%18% Help C:\Windows\Help
%20% Fonts C:\Windows\Fonts
%21% Viewers C:\Windows\system32\viewers
%23% Color C:\Windows\system32\spool\drivers\color
%24% Apps C:\
%25% Shared C:\Windows
%30% Boot C:\
%50% System16 C:\Windows\system
%51% Spool C:\Windows\system32\spool
%52% Spooldrivers C:\Windows\system32\spool\drivers\w32x86
%53% Userprofile C:\Documents and Settings\username
%54% Loader C:\
%55% Printprocessor C:\Windows\system32\spool\Prtprocs\w32x86
%16406% All Users\Start Menu C:\Documents and Settings\All Users\Start Menu
%16407% All Users\Start Menu\Programs C:\Documents and Settings\All Users\Start Menu\Programs
%16408% All Users\Start Menu\Programs\Startup C:\Documents and Settings\All Users\Start Menu\Programs\Startup
%16409% All Users\Desktop C:\Documents and Settings\All Users\Desktop
%16415% All Users\Favorites C:\Documents and Settings\All Users\Favorites
%16419% All Users\Application Data C:\Documents and Settings\All Users\Application Data
%16422% Program Files C:\Program Files
%16425% system 32 on RISC C:\Windows\system32
%16426% Program Files on RISC C:\Program Files
%16427% Program Files\Common C:\Program Files\Common
%16428% x86 Program Files\Common on RISC C:\Program Files\Common
%16429% All Users\Templates C:\Documents and Settings\All Users\Templates
%16430% All Users\Documents C:\Documents and Settings\All Users\Documents
%16437% All Users\Documents\My Music C:\Documents and Settings\All Users\Documents\My Music
%16438% All Users\Documents\My Pictures C:\Documents and Settings\All Users\Documents\My Pictures
5.Manufacturer节
Manufacturer节指明供应商及其对应Models接的名称,只有安装驱动程序才需要,其各项的格式如下:
%strkey%=models-section-name
其中
“strkey”代表设备制造的名字,其字符串值在String节中定义;
“models-section-name”指出Models节的名称,作为驱动程序安装入口
6.Models节
Models节指明Install/DDInstall节的名称、设备的硬件ID和兼容ID等信息,其节名称由Manufacturer节指定。其各项的格式如下:
device-description=install-section-name,hw-id[,compatiable-id…]
其中,
“device-description”指出设备的表述信息,他可以是一个字符串,也可以使一个%strkey%;
“install-section-name”指出Install/DDInstall节的名称;
“hw-id”指出设备的硬件ID
;“compatiable-id”指出设备的兼容ID。
7. Install/DDInstall节
Install/DDInstall节指明需复制的文件、向注册表中添加的内容等信息
说明:[DefaultInstall]节在进行安装前都会默认先执行
1、如果是安装驱动程序则其节名称由Models节指定;
2、如果是发布软件包,则作为发布软件包入口;
eg:
[CopyFiles=@filename | CopyFiles-section-name [,CopyFiles-section-name] ...]
[CopyINF=filename1.inf[,filename2.inf]...]
[AddReg= AddReg -section-name [,AddReg -section-name]...]
[Include=filename1.inf[,filename2.inf]...]
[Needs= Needs -section-name [,Needs -section-name]...]
[Delfiles= Delfiles -section-name [,Delfiles -section-name]...]
[Renfiles= Renfiles -section-name [,Renfiles -section-name]...]
[DelReg= DelReg -section-name [,DelReg -section-name]...]
[BitReg= BitReg -section-name [,BitReg -section-name]...]
[ProfileItems= ProfileItems -section-name [,ProfileItems -section-name]...]
[UpdateInis= UpdateInis -section-name [,UpdateInis -section-name]...]
[UpdateIniFields= UpdateIniFields -section-name [,UpdateIniFields -section-name]...]
[Ini2Reg= Ini2Reg -section-name [,Ini2Reg -section-name]...]
[RegisterDlls= RegisterDlls -section-name [,RegisterDlls -section-name]...]
[UnregisterDlls= UnregisterDlls -section-name [,UnregisterDlls -section-name]...]
[DefaultInstall] 和 [DefaultUnInstall] 是系统保留的节名,用于默认的安装和卸载。
系统保留的安装节名还包括:[ClassInstall32]|[ClassInstall32.nt] |[ClassInstall32.ntx86] |[ClassInstall32.ntia64] | [ClassInstall32.ntamd64] 等。
这些节所包含的项都是一样,项其实就是操作命令。
下表列出了其包含的常用项。
Install/DDInstall节中的常用项
项 | 说明 |
DriverVer | 指明驱动程序的版本信息,格式为:mm/dd/yyyy[,x.y.z] |
CopyFiles | 指明需复制的文件,格式为: CopyFiles=@filename|file-list-section[,file-list-section]... |
AddReg | 指明向注册表中添加的其他INF文件按,格式为: AddReg=add-registry-section[,add-registry-section]… |
Include | 指明安装时需要的其他INF文件,格式为: Include=filename.inf[,filename2.inf]… |
Needs | 指明安装时所需的特定INF文件,格式为: Needs=inf-section-name[,inf-section-name]… |
Delfiles | 指明需删除的文件,格式为: Delfiles=inf-section-name[,inf-section-name]… |
RenFiles | 指明需重命名的文件,格式为: Renfiles=inf-section-name[,inf-section-name]… |
DelReg | 指明需删除的注册表内容,格式为: DelReg=del-registry-section[,del-registry-section]… |
Install/DDInstall节中的常用项的详细介绍。
① CopyFiles项:它是Install/DDInstall节中的一个基本指令,用于指明需要复制的文件。
其中:
“filename”指出目标文件名;
“file-list-section”是其创建的文件列表节,该节格式为[指定针对该节下的所有文件都需要做复制]
[file-list-section]
destination-file-name[,source-file-name][,temporary-file-name][,flag]
其中,
“destination-file-name”指出目标文件名;
“source-file-name”指出源文件名,如果其和目标文件名相同,则可忽略该参数(如果忽略","需要保留);
“temporary-file-name”指出复制操作过程中所需要的临时文件名,他只适用于Windows 98;“flag”指出该文件的一些处理方法,其取之情况如下表。
CopyFiles项中的flag参数
值 | 符号 | 说明 |
0x00000400 | COPYFLG_REPLACEONLY | 仅替换目标目录中的文件 |
0x00000800 | COPYFLG_NODECOMP | 复制并不解压缩 |
0x00000008 | COPYFLG_FORCE_FILE_IN_USE | 将源文件赋值为临时文件名,以重新命名 |
0x00000010 | COPYFLG_NO_OVERWRITE | 不替换原有文件 |
0x00001000 | COPYFLG_REPLACE_BOOT_FILE | 强制用户重新引导系统 |
0x00002000 | COPYFLG_NOPRUNE | 强制复制文件 |
0x00000020 | COPYFLG_NO_VERSION_DIALOG | 不覆盖新版本的文件 |
0x00000004 | COPYFLG_NOVERSIONCHECK | 可覆盖任何版本的文件 |
0x00000040 | COPYFLG_OVERWRITE_ORDER_ONLY | 仅覆盖旧版本的文件 |
0x00000001 | COPYFLG_WARN_IF_SKIP | 当用户跳过文件时发出警告 |
0x00000002 | COPYFLG_NOSKIP | 不允许用户跳过文件 |
② AddReg项:它是Install/DDInstall节所必须包含的指令,用于指明需项注册表中添加的内容。
其“add-registry-section”是它创建的添加注册表节,该节的格式为
[add-registry-section]
reg-root, [subkey], [value-entry-name], [flags], [value]
其中,“reg-root”指出注册表树的根目录,它的取值在下表中;
“subkey”指出reg-root下的子目录(或称子键);
“value-entry-name”指出要增加的注册表值;
“flags”指出其对注册表的一些处理方法,取值在下面的flags表中;
“value”指出新增加注册表值的数据。
AddReg项中的reg-root参数
值 | 说明 |
HKCR | HKEY_CLASSES_ROOT |
HKCU | HKEY_CURRENT_USER |
HKLM | HKEY_LOCAL_MACHINE |
HKU | HKEY_USER |
HKR | 被安装设备的注册表键 |
AddReg项中的flags参数
值 | 符号 | 说明 |
0x00000000 | FLG_ADDREG_TYPE_SZ | value为REG_SZ类型 |
0x00000001 | FLG_ADDREG_BINVALUETYPE | value为2进制数据 |
0x00000002 | FLG_ADDREG_NOCLOBBER | 不替换已有注册表中的value |
0x00000004 | FLG_ADDREG_DELVAL | 从注册表中删除subkey或 value-entry-name |
0x00000010 | FLG_ADDREG_KEYONLY | 仅建立subkey,忽略value-entry-name 和value |
0x00000020 | FLG_ADDREG_OVERWRITEONLY | 仅当value-entry-name时替换value |
0x00010000 | FLG_ADDREG_TYPE_MULTI_SZ | value为REG_MULTI_SZ类型 |
0x00000008 | FLG_ADDREG_APPEND | 添加value至已有注册表值 |
0x00020000 | FLG_ADDREG_TYPE_EXPEND_SZ | value为REG_EXPAND_SZ类型 |
0x00010001 | FLG_ADDREG_TYPE_DWORD | value为REG_DWORD类型 |
0x00020001 | FLG_ADDREG_TYPE_NONE | value为REG_NONE类型(Windows2000) |
③ DelFiles项:它是Install/DDInstall节中的可选指令,用于指明需删除的文件。
其“file-list-section”是它创建的文件列表节,该节的格式为
[file-list-section]
destination-file-name[,,,flag]
其中,“destination-file-name”指出目标文件名;“flag”指出该文件的一些处理方法,其取值如下表。
DelFiles项中的flag参数
值 | 符号 | 说明 |
0x0000001 | DELFLG_IN_USE | 在其安装处理操作完成后再删除该文件 |
0x0001000 | DELFLG_IN_USE1 | 功能与DELFLG_IN_USE一样,仅适用Windows2000 |
④RenFiles项:它是Install/DDInstall节中的可选指令,用于指明需重命名的文件。
其“file-list-section”是它创建的文件列表节,该节的格式为
[file-list-section]
new-dest-file-name, old-source-file-name
其中,“new-dest-file-name”指出该文件的新文件名;“old-source-file-name”指出其原有文件名。
⑤DelReg项:它是Install/DDInstall节中的可选指令,用于指明需从注册表中删除的内容。
其“del-registry-section”是它创建的删除注册表节,该节的格式为
[del-registry-section]
reg-root, subkey [,value-entry-name]
其中,“reg-root”指出该注册表树中的根目录,取值与AddReg的ret-root相同; “subkey”指出reg-root下的子目录(或称子键);“value-entry-name”指出要删除的注册表值。
8.DDInstall.Services节
DDInstall.Services节指明驱动程序安装的详细信息,他只是用于Windows 2000.他的节名称为[install-section-name.Services],其“install-section-name”由Models节指定。下表列出了其包含的常用项。
DDInstall.Services节中的常用项
项 | 说明 |
AddService | 控制驱动程序的安装过程,格式为 AddService=ServiceName,[flags],service-install-section [,event-log-install-section[,[EventLogType][,EventName]]]… |
DelService | 删除一个或多个已有的驱动程序,格式为 DelService=ServiceName [,[flags][,[EventLogType][,EventName]]]… |
Include | 指明安装时所需的其他INF文件,格式为 Include =filename.inf [,filename2.inf]… |
Needs | 之敏感转世所需要的特定INF文件,格式为 Needs = inf-section-name[,inf-section-name]… |
主要项进行详细介绍。
① AddService项:它是DDInstall.Services节所必须包含的指令,用于控制设备驱动程序的安装过程。
其中,
“ServiceName”指出驱动程序的名字;
“flags”指出一个或多个系统定义的标识,其取值情况如下表;
“event-log-install-section”是其创建的事件日志安装,下表中列出了该节所包含的常用项;
“service-install-section”是其创建的服务安装节,下表中列出了该节所包含的常用项;
“EventLogType”指出事件日志的类型,其取值为System、Security和Application;
“EventName”指出事件日志的名字。
AddService项的常用flags参数
值 | 符号 | 说明 |
0x00000002 | SPSVCINST_ASSOCSERVICE | 指明其为PnP功能驱动程序 |
0x00000008 | SPSVCINST_NOCLOBBER_DISPLAYNAME | 不覆盖指定服务的名字 |
0x00000100 | SPSVCINST_NOCLOBBER_DESCRIPTION | 不覆盖指定服务的描述 |
0x00000010 | SPSVCINST_NOCLOBBER_STARTTYPE | 不覆盖指定服务的启动类型 |
0x00000020 | SPSVCINST_NOCLOBBER_ERRORCONTROL | 不覆盖指定服务的差错控制值 |
event-log-install-section节中的常用项
项 | 说明 |
AddReg | 指明向注册表中添加的内容,格式如下 AddReg=add-registry-section[,add-registry-section]… |
DelReg | 指明需删除的注册表内容,格式如下 DelReg=del-registry-section[,del-registry-section]… |
BitReg | 有效但几乎无用,格式如下 BitReg=bit-registry-section[,bit-registry-section]… |
DisplayName | 驱动程序的名字,为字符串值 |
Description | 驱动程序的描述,为字符串值 |
ServiceType | 驱动程序的类型,为特定16进制数 |
StartType | 驱动程序的启动类型,为特定16进制数 |
ErrorControl | 驱动程序的差错控制级别,为特定16进制数 |
ServiceBinary | 驱动程序的完整路径名:%dirid% /filename |
一下是对event-log-install-section节中的常用项的主要项进行详细介绍。
<1>ServiceType项:指明驱动程序的类型,取值情况如下表。
ServiceType项的取值
值 | 符号 | 说明 |
0x00000001 | SERVICE_BOOT_START | 内核模式驱动程序 |
0x00000002 | SERVICE_KERNEL_FILE_SYSTEM_DRIVER | 上层网络驱动程序或文件系统 |
0x00000010 | SERVICE_WIN32_OWN_PROCESS | Win32应用程序 |
0x00000020 | SERVICE_WIN32_SHARE_PROCESS | Win32应用程序 |
<2>StartType项:指明驱动程序的启动类型,其取值情况如下表。
StartType项的取值
值 | 符号 | 说明 |
0x0 | SERVICE_BOOT_START | 由操作系统加载程序启动 |
0x1 | SERVICE_SYSTEM_START | 由操作系统初始化过程中启动 |
0x2 | SERVICE_AUTO_START | 由服务控制管理器启动 |
0x3 | SERVICE_DEMAND_START | 由PnP管理器或服务控制管理器按需启动 |
0x4 | SERVICE_DISABLE | 禁止启动 |
<3>ErrorControl项:指明驱动程序的差错控制级别,其取值情况如下表。
ErrorControl项的取值
值 | 符号 | 说明 |
0x0 | SERVICE_ERROR_IGNORE | 不显示警告信息 |
0x1 | SERVICE_ERROR_NORMAL | 显示警告信息 |
0x2 | SERVICE_ERROR_SERVICE | 当驱动程序加载失败时,系统将使用其注册的LastKnownGood重试,并忽略其后的错误 |
0x3 | SERVICE_ERROR_CRITICAL | 当驱动程序加载失败时,系统将使用其注册的LastKnownGood重试,并对其后的错误进行检验 |
② DelService项:它是DDInstall.Service节中的可选指令,用于删除一个或多个已有的设备驱动程序。
其中,
“ServiceName”指出驱动程序的名字;
“flags”指出一个或多个系统定义的标识,取值见下表;
“EventLogType”指出事件日志的类型,其取值为System、Security或Application;“EventName”指出事件日志的名字。
DelService项的flags参数
符号 | 说明 |
SPSVCINST_DELETEEVENTLOGENTRY | 删除与ServiceName有关的事件日志 |
SPSVCINST_STOPSERVICE | 在删除之前首先停止服务 |
9、[Optional Components]
用于列出用户单击“控制面板”上的“添加/删除程序”图标,单击“安装 Windows”选项卡,然后单击“从磁盘安装”按钮时,显示的 installsection 节。在列表中installsection节会当作复选框显示。如:
[Optional Components]
Codec4WMP
[Codec4WMP]
OptionDesc ="Codec4WMP addon pack"
Tip ="Codec4WMP by仙乃日"
Modes =0,1,2,3
CopyFiles=copy.sys,copy.wmp,copy.wmp.Codec4WMP
Registerdlls=register.codecs
AddReg=Codec4WMP.Reg
DelReg=deloldwmpreg
ProfileItems =codec.Config
UpdateInis=codec.Config1
10、[ControlFlags]
ExcludeFromSelect = *
删除所有(如果*指定)或设备,从某些用户界面显示,用户从中选择一个,预计安装特定设备指定列表。
对于基于NT的操作系统,指定的设备将不会显示在添加硬件向导,但会找到新的硬件和硬件更新向导显示。
11、String节
String节指明一些列字符串,其所含各项的格式为
strkey=[“]some string[“]
其中,“strkey”指出字符串的名字,它只能包含字母和数字;“some string”为字符串的内容。
12、说明
特定变量:
EXTRACT_DIR:cab文件展开后的目录
OBJECT_DIR:window下的Download Program FIles的目录
具体调用:
winxp上,之后不一样,可以自己查找
rundll32.exe setupapi,InstallHinfSection MPS_MP_HAL 132 %windir%\inf\hal.inf
VOID CALLBACK InstallHinfSection(
__in HWND hwnd,
__in HINSTANCE ModuleHandle,
__in PCTSTR CmdLineBuffer,
__in INT nCmdShow
);
13、具体实例详解
; test.inf
;整个配置文件安装成功后会在注册表生成一个实例子健 具体位置为:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
;--------- Version Section ---------------------------------------------------
[Version]
;可以是$Chicage$、$Windows NT$(含有一个空格)、$Windows 95$(含有一个空格)之一,定界符$必不可少,且这些串是不分大小写的。
;如果Signature的值不是这些有效的串之一,该INF文件就被认为无效
Signature="$WINDOWS NT$"
;INF文件的提供者
Provider=drsn_Device
;INF文件的版本信息,时间和版本不变的情况下,修改了SYS文件,重新安装INF文件是看不到SYS变化的
;因为系统已经存根了此版本的INF和SYS,它会直接加载已有的文件,调试SYS特别要主要这个问题
;如果使用VS2012编译,它会自动帮你填写这里,比较省心
DriverVer=08/31/2013,8.33.48.258
;如果设备是一个标准类别,使用标准类的名称和GUID 否则创建一个自定义的类别名称,并自定义它的GUID
;自定义的类别在注册表中 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\ 有显示
Class=drsnDevice
ClassGuid={BDC0EAC4-AC4B-46af-82EA-C4958B686515}
;--------- SourceDiskNames and SourceDiskFiles Section -----------------------
;这里两项的设置效果是 加载INF当前目录下的SYS文件
[SourceDisksNames]
1 = %DiskName%,,,
[SourceDisksFiles]
Name_Files_Driver = 1,,
;--------- ClassInstall/ClassInstall32 Section -------------------------------
;如果不是标准类别设备,这里的配置必须的
[ClassInstall32]
Addreg=Class_AddReg
;对应的注册表是 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\
[Class_AddReg]
HKR,,,,%DeviceClassName%
HKR,,Icon,,"-5"
;--------- DestinationDirs Section -------------------------------------------
;把文件复制到相应的目录下,在win2000及其以后系统,12表示%windir%/system32/drivers
;win98中12表示%windir%/system/IoSubsys 所以为了兼容大家都写成10,System32\Drivers
[DestinationDirs]
Name_Files_Driver = 12
;--------- Manufacturer and Models Sections ----------------------------------
;这里是设置模型相关的选项,注意这里VS默认生成的标准设备的配置 如:%ManufacturerName%=Standard,NT$ARCH$
;如果不是标准类别设备这里必须修改,要不然最后加载的时候会出现259错误
[Manufacturer]
%ManufacturerName%=Mfg0
;这里是模型节的节名,和硬件ID 这个ID可以自定义
[Mfg0]
%DeviceDesc%=SysInstall, PCI\VEN_8888&DEV_8888
;---------- DDInstall Sections -----------------------------------------------
;这里需要注意WIN2000及其以上的系统这里有个.NT,如果是98这里是[SysInstall],必须要正确设置
[SysInstall.NT]
CopyFiles=Name_Files_Driver
AddReg=Install_NT_AddReg
;这里的drsnWDM是注册表中的服务名 具体地址是 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
[SysInstall.NT.Services]
Addservice = drsnWDM, 0x00000002, Sys_AddService
;服务的具体选项
[Sys_AddService]
DisplayName = %SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
;这个地方虽然和[Name_Files_Driver]相同但是不能引用,所以只能照实来写
ServiceBinary = %12%\test.sys
[Install_NT_AddReg]
HKLM, "System\CurrentControlSet\Services\drsnWDM\Parameters",\
"BreakOnEntry", 0x00010001, 0
; --------- Files (common) -------------
;sys文件名 便于配置文件其它地方使用
[Name_Files_Driver]
test.sys
;--------- Strings Section ---------------------------------------------------
;字符串设置 便于配置文件其它地方使用
[Strings]
ProviderName="drsn"
ManufacturerName="drsn soft"
DiskName="test Source Disk"
DeviceDesc="test protect"
SvcDesc="drsn"
DeviceClassName="drsn_Device"
以上INF是对32位驱动的支持,如果要同时支持32位和64位 兼容INF如下:
;
; Ring0.inf
;整个配置文件安装成功后会在注册表生成一个实例子健 具体位置为:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
;--------- Version Section ---------------------------------------------------
[Version]
;可以是$Chicago$、$Windows NT$(含有一个空格)、$Windows 95$(含有一个空格)之一,定界符$必不可少,且这些串是不分大小写的。
;如果Signature的值不是这些有效的串之一,该INF文件就被认为无效
Signature="$Windows NT$"
;INF文件的提供者
Provider=drsn_Device
;INF文件的版本信息,时间和版本不变的情况下,修改了SYS文件,重新安装INF文件是看不到SYS变化的
;因为系统已经存根了此版本的INF和SYS,它会直接加载已有的文件,调试SYS特别要主要这个问题
;如果使用VS2012编译,它会自动帮你填写这里,比较省心
DriverVer=
;如果设备是一个标准类别,使用标准类的名称和GUID 否则创建一个自定义的类别名称,并自定义它的GUID
;自定义的类别在注册表中 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\ 有显示
Class=drsnDevice
ClassGuid={BDC0EAC4-AC4B-46af-82EA-C4958B686515}
;--------- ClassInstall/ClassInstall32 Section -------------------------------
;如果不是标准类别设备,这里的配置必须的
[ClassInstall32]
Addreg=Class_AddReg
;对应的注册表是 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\
[Class_AddReg]
HKR,,,,%DeviceClassName%
HKR,,Icon,,"-5"
;--------- SourceDiskNames and SourceDiskFiles Section -----------------------
;这里两项的设置效果是 加载INF当前目录下的SYS文件
[SourceDisksNames]
1 = %DiskName%,,
[SourceDisksFiles]
Name_Driver_File = 1,,
Name_Driver_File64 = 1,,
;--------- DestinationDirs Section -------------------------------------------
;把文件复制到相应的目录下,在win2000及其以后系统,12表示%windir%/system32/drivers
;win98中12表示%windir%/system/IoSubsys 所以为了兼容大家都写成10,System32\Drivers
;由于INF同时支持32位,64位所以这里要写上2中情况
[DestinationDirs]
Name_Driver_File = 12
Name_Driver_File64 = 12
;--------- Manufacturer and Models Sections ----------------------------------
;这里是设置模型相关的选项,注意这里VS默认生成的标准设备的配置 如:%ManufacturerName%=Standard,NT$ARCH$
;如果不是标准类别设备这里必须修改,要不然最后加载的时候会出现259错误
;NT表示32位,NTAMD64表示64位
[Manufacturer]
%ManufacturerName%=Device,NT,NTAMD64
;这里是模型节的节名,和硬件ID 这个ID可以自定义
[Device.NT]
%DeviceDesc%=SysInstall, PCI\VEN_8888&DEV_8888
[Device.NTAMD64]
%DeviceDesc%=SysInstall, PCI\VEN_8888&DEV_8888
;---------- DDInstall Sections -----------------------------------------------
;这里需要注意WIN2000及其以上的系统这里有个.NT,如果是98这里是[SysInstall],必须要正确设置
[SysInstall.NT]
CopyFiles=Name_Driver_File
AddReg=Install_NT_AddReg
;这里的drsnWDM是注册表中的服务名 具体地址是 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
[SysInstall.NT.Services]
Addservice = drsnWDM, 0x00000002, Sys_AddService
;服务的具体选项
[Sys_AddService]
DisplayName = %SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
;这个地方虽然和[Name_Driver_File]相同但是不能引用,所以只能照实来写
ServiceBinary = %12%\test.sys
[Install_NT_AddReg]
HKLM, "System\CurrentControlSet\Services\drsnWDM\Parameters",\
"BreakOnEntry", 0x00010001, 0
;---------------------64位支持---------------
[SysInstall.NTAMD64]
CopyFiles=Name_Driver_File64
AddReg=Install_NT_AddReg64
[SysInstall.NTAMD64.Services]
Addservice = drsnWDM, 0x00000002, Sys_AddService64
[Sys_AddService64]
DisplayName = %SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\test64.sys
[Install_NT_AddReg64]
HKLM, "System\CurrentControlSet\Services\drsnWDM\Parameters",\
"BreakOnEntry", 0x00010001, 0
; --------- Files (common) -------------
;sys文件名 便于配置文件其它地方使用
[Name_Driver_File]
test.sys
[Name_Driver_File64]
test64.sys
;--------- Strings Section ---------------------------------------------------
;字符串设置 便于配置文件其它地方使用
[Strings]
ProviderName="drsn"
ManufacturerName="drsn soft"
DiskName="drsn WDM Device Source Disk"
DeviceDesc="drsn WDM Device"
SvcDesc="drsn"
DeviceClassName="drsn_Device"
14.加载oxc控件
[version]
signature="$CHICAGO$"
LiveCtrl=1.0.0.1
;-------------入口------------
[DefaultInstall]
CopyFiles=config.files,app.files ;拷贝文件
RegisterOCXs=RegisterFiles ;注册控件
[RInstallApplicationFile]
DelFiles=config.files,app.files
CopyFiles=config.files,app.files
RegisterOCXs=RegisterFiles
[DestinationDirs]
;默认安装路径
DefaultDestDir=24,Program Files\LiveCtrl
;---------cab包含多级目录文件--------------
[config.files]
/images/about.png
/images/gis/alarm.png
[app.files]
/debug/LiveControl.dll
/debug/LiveStreamService.dll
/debug/ACEd.dll
/debug/boost_thread-vc90-mt-gd-1_46_1.dll
/debug/boost_date_time-vc90-mt-gd-1_46_1.dll
/debug/boost_system-vc90-mt-gd-1_46_1.dll
/debug/MtcpHandlerD.dll
/debug/RimiMechanismD.dll
/debug/RsioMechanismD.dll
/debug/Microsoft.VC90.ATL.manifest
/debug/Microsoft.VC90.DebugCRT.manifest
/debug/atl90.dll
/debug/msvcp90d.dll
/debug/msvcr90d.dll
/debug/TestSupportD.dll
/debug/avcodec-55.dll
/debug/avdevice-55.dll
/debug/avfilter-4.dll
/debug/avformat-55.dll
/debug/avutil-52.dll
/debug/postproc-52.dll
/debug/swresample-0.dll
/debug/swscale-2.dll
/debug/WtDecoderD.dll
/debug/WtPlayerD.dll
[SourceDisksNames]
;1为磁盘驱动器编号,描述信息,文件名字,所在路径
1=%DiskName%,LiveCtrl.cab,1
[SourceDisksFiles]
LiveCtrl.cab=1
;特别修正说明,如果该节存在在部分电脑可能会无法进行下载,需要参考者自己尝试,如有谁发现更规则的inf的书写格式,请告诉我(通过回复),我想学习,谢谢!
[Add.Code]
LiveControl.dll=LiveControl.dll
LiveStreamService.dll=LiveStreamService.dll
ACEd.dll=ACEd.dll
boost_thread-vc90-mt-gd-1_46_1.dll=boost_thread-vc90-mt-gd-1_46_1.dll
boost_date_time-vc90-mt-gd-1_46_1.dll=boost_date_time-vc90-mt-gd-1_46_1.dll
boost_system-vc90-mt-gd-1_46_1.dll=boost_system-vc90-mt-gd-1_46_1.dll
MtcpHandlerD.dll=MtcpHandlerD.dll
RimiMechanismD.dll=RimiMechanismD.dll
RsioMechanismD.dll=RsioMechanismD.dll
TestSupportD.dll=TestSupportD.dll
Microsoft.VC90.ATL.manifest=Microsoft.VC90.ATL.manifest
Microsoft.VC90.DebugCRT.manifest=Microsoft.VC90.DebugCRT.manifest
atl90.dll=atl90.dll
msvcp90d.dll=msvcp90d.dll
msvcr90d.dll=msvcr90d.dll
avcodec-55.dll=avcodec-55.dll
avdevice-55.dll=avdevice-55.dll
avfilter-4.dll=avfilter-4.dll
avformat-55.dll=avformat-55.dll
avutil-52.dll=avutil-52.dll
postproc-52.dll=postproc-52.dll
swresample-0.dll=swresample-0.dll
swscale-2.dll=swscale-2.dll
WtDecoderD.dll=WtDecoderD.dll
WtPlayerD.dll=WtPlayerD.dll
[LiveControl.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
RegisterServer=yes
FileVersion=1,0,0,1
[LiveStreamService.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[ACEd.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=6,0,1,0
[boost_thread-vc90-mt-gd-1_46_1.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[boost_date_time-vc90-mt-gd-1_46_1.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[boost_system-vc90-mt-gd-1_46_1.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[MtcpHandlerD.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[RimiMechanismD.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=2,5,3,0
[RsioMechanismD.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=1,0,1,0
[TestSupportD.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[Microsoft.VC90.ATL.manifest]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[Microsoft.VC90.DebugCRT.manifest]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[atl90.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=9,0,30729,4148
[msvcp90d.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=9,0,30729,4148
[msvcr90d.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=9,0,30729,4148
[avcodec-55.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[avdevice-55.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[avfilter-4.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[avformat-55.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[avutil-52.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[postproc-52.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[swresample-0.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[swscale-2.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[WtDecoderD.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
[WtPlayerD.dll]
file-win32-x86=thiscab
DestDir=24,Program Files\LiveCtrl\debug
FileVersion=0,0,0,0
;注册
[RegisterFiles]
%24%\Program Files\LiveCtrl\debug\LiveControl.dll
[String]
DiskName="Cab Name"