Windows 驱动开发笔记(七)

来源:互联网 发布:充值软件加盟 编辑:程序博客网 时间:2024/05/08 17:13

Windows 驱动开发笔记(七)
一个驱动写好以后。就需要编写安装程序了。我们先看一下一个例子。在行解释。
;   
;
;        Created by GenINF.
;
;
 
[Version]
Signature = "$Windows NT$"
Class=Unknown
ClassGUID={4d36e97e-e325-11ce-bfc1-08002be10318}
Provider=%quartz%
CatalogFile=hello.cat
DriverVer= 5/5/2008

[DestinationDirs]
hello.Files.x86_12 = 12

[SourceDisksNames.x86]
0=%Desc_x860%

[SourceDisksNames.ia64]


[SourceDisksFiles.x86]
hello.sys=0,./,

[SourceDisksFiles.ia64]


[Manufacturer]
%quartz%=quartz

[quartz]
%helloDesc%=hello_Inst,23423423

[hello_Inst.ntx86]
CopyFiles = hello.Files.x86_12

[hello_Inst.ntx86.Services]
AddService = hello,0x00000002,hello_Service_Instx86,

[hello_Service_Instx86]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_IGNORE%
ServiceBinary = %12%/hello.sys


[hello.Files.x86_12]
hello.sys

[hello_EventLog_Inst]
AddReg = hello_EventLog_Inst.AddReg
 
[hello_EventLog_Inst.AddReg]
HKR,,EventMessageFile,%REG_EXPAND_SZ%,"%%SystemRoot%%/System32/IoLogMsg.dll"
HKR,,TypesSupported,%REG_DWORD%,7


[Strings]

;  *******Localizable Strings*******
quartz= "quartz,Co., Ltd."
Desc_x860= "quartz,ctl Portsdrivers"
helloDesc= "hello,world"

;  *******Non Localizable Strings*******

SERVICE_BOOT_START = 0x0
SERVICE_SYSTEM_START = 0x1
SERVICE_AUTO_START = 0x2
SERVICE_DEMAND_START = 0x3
SERVICE_DISABLED = 0x4

SERVICE_KERNEL_DRIVER = 0x1
SERVICE_ERROR_IGNORE = 0x0
SERVICE_ERROR_NORMAL = 0x1
SERVICE_ERROR_SEVERE = 0x2
SERVICE_ERROR_CRITICAL = 0x3

REG_EXPAND_SZ = 0x00020000
REG_DWORD = 0x00010001
-----------------------------------------------------------------------------------

[Version]
Signature = "$Windows NT$" ;参数可以取值 $Windows NT$, $Chicago$, or $Windows 95$.如果不是以上这些字符串,则inf文件报错。
Class=Unknown
ClassGUID={4d36e97e-e325-11ce-bfc1-08002be10318} ;详细信息见DDK Programmer's Guide,不可以是任意值。这里是与未知匹配
Provider=%quartz% ;为一个变量。参考 [Strings] quartz= "quartz,Co., Ltd."
CatalogFile=hello.cat

DriverVer= 5/5/2008


[SourceDisksFiles.x86]
hello.sys=0,./, ;驱动程序文件名和源路径

[hello_Service_Instx86]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START% ;驱动启动方式,详细信息见DDK Programmer's Guide
ErrorControl = %SERVICE_ERROR_IGNORE%
ServiceBinary = %12%/hello.sys
有了这个inf文件就可以为用户自行安装了。
好了我们可以安装这个设备了。打开控制面板,双击“添加/删除硬件”,选择“添加/排除设备故障”->“添加新设备”->“否,我想从列表选择硬件”->“其它设备”->“从磁盘安装”,选择 Hello.INF 所在的路径,然后安装。
完成后可以在设备列表中看到该设备了。

原创粉丝点击