Inf 格式詳解

來源:互聯網
上載者:User
INF 檔案必須包含以下規則:

節( Sections )開始於由中括弧 ([]) 擴起來的節名

必須包含版本資訊節以表明自己屬於 win95 還是 winnt4 格式。

值 (Value) 由 %strkey% 替代的運算式字串表達組成, strkey 必須在 strings 節中定義。如果出現 % ,則用 %% 替代。

Setup 程式使用以下各節 :

[Version] 必須包含在 INF 檔案中,表明 inf 檔案格式

[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 檔案。

Class-name

此參數用於安裝裝置驅動。詳細資料見 DDK Programmer’s Guide.

GUID

此參數用於安裝裝置驅動。詳細資料見 DDK Programmer’s Guide.

INF-creator

標示 INF 的建立者 . 典型的情況,此值為 inf 檔案的建立者所在組織

filename.inf

INF 檔案必須包含 SourceDisksFiles 和 SourceDisksNames 節。這些檔案的描述檔案通常命名為 LAYOUT.INF. 如果檔案名稱不是特別指定, SourceDisksNames 和 SourceDisksFiles 必須出現在當前 inf 檔案中

以下為典型的例子:

[Version]

Signature=”$Windows NT$”

Class=Mouse

ClassGUID={4D36E96F-E325-11CE-BFC1-08002BE10318}

Provider=%Provider%

LayoutFile=layout.inf

[Strings]

Provider=”Corporation X”

[Install] 此節指定包含的安裝指令節,每一個條目將會成為一節

[install-section-name]

LogConfig=log-config-section-name[,log-config-section-name]…

Copyfiles=file-list-section[,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]…

以上各條目並非全部必須。節名必須為可見字元。每個條目包含一到多個節。第一個命名之後的所有命名必須以,引導。條目指定了必須出現在 INF 檔案中的各節。 CopyFiles 則可例外(如果沒有任何檔案被拷貝)。

如果安裝驅動程式,僅僅使用 LogConfig 條目。詳見 DDK Programmer’s Guide.

CopyFiles 條目中可以包含特殊字元 @ 以直接拷貝一個單一檔案。檔案將拷貝到 DefaultDestDir, DestinationDirs 節包含了 DefaultDestDir 的描述。如例子:

[MyInstall]

CopyFiles= @MyFile.exe

此檔案將拷貝到預設目標目錄。

為適應不同平台,可以在 install 節後加上不同的尾碼。可以出現 defaultInstall.nt 這樣的節名。 install-section-name 可選的尾碼:

Extension Platform

.Win Windows 95

.NT Windows NT (all platforms)

.NTx86 Windows NT (x86 only)

.NTMIPS Windows NT (MIPS only)

.NTAlpha Windows NT (Alpha only)

.NTPPC Windows NT (PowerPC only)

以下例子展示了如何出現兩個 copyfiles 節:

[Ser_Inst]

CopyFiles=Ser_CopyFiles, mouclass_CopyFiles

[Ser_CopyFiles]

sermouse.sys

[mouclass_CopyFiles]

mouclass.sys

[Add Registry] 描述如何增加註冊表項目。 add -registry-section 節名必須處現在 install 節中的 AddReg 條目中。

[add-registry-section]

reg-root-string, [subkey], [value-name], [flags], [value]

[reg-root-string, [subkey], [value-name], [flags], [value]]

reg-root-string 註冊表的根名:

HKCR HKEY_CLASSES_ROOT.

HKCU HKEY_CURRENT_USER.

HKLM HKEY_LOCAL_MACHINE.

HKU HKEY_USERS.

HKR 相關於 SetupInstallFromInfSection. 節中指定的值

subkey

可選,例如 key1\key2\key3….

value-name

可選,標示 subkey 的值名稱。對於字串類型可以空,標示預設字串值

flag 實值型別的標示

Value Meaning

FLG_ADDREG_BINVALUETYPE The value is “raw” data.

FLG_ADDREG_NOCLOBBER 如果註冊表中出現不要覆蓋此值 .

FLG_ADDREG_DELVAL 從註冊表中刪除此鍵

FLG_ADDREG_APPEND 追加一個值到已存值中,僅僅支援 REG_MULTI_SZ 值

FLG_ADDREG_TYPE_MASK Mask.

FLG_ADDREG_TYPE_SZ REG_SZ 類型

FLG_ADDREG_TYPE_MULTI_SZ REG_MULTI_SZ.

FLG_ADDREG_TYPE_EXPAND_SZ REG_EXPAND_SZ.

FLG_ADDREG_TYPE_BINARY REG_BINARY.

FLG_ADDREG_TYPE_DWORD REG_DWORD.

FLG_ADDREG_TYPE_NONE REG_NONE.

Windows 95 安裝程式將視擴充資料類型為 REG_SZ or REG_BINARY.

value

可選 . 16 進值或者字串

[CopyFiles] 此類節可以有多個,定義於 install 節中。

[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

源檔案名稱,如果沒有給出目標檔案名,那麼此名也是目標檔案名 .

temporary-file-name

被忽略, setup 函數自動處理臨時檔案 .

flag

可選,用於控制檔案如何被拷貝。你必須配置實際值

COPYFLG_WARN_IF_SKIP (0×00000001)

如果使用者試圖在發生一個錯誤後跳過將顯示警告資訊

COPYFLG_NOSKIP (0×00000002)

不允許使用者跳過拷貝此檔案

COPYFLG_NOVERSIONCHECK (0×00000004)

如果檔案存在於目標目錄,忽略

COPYFLG_FORCE_FILE_IN_USE (0×00000008)

替換被使用得檔案?,當拷貝時檔案被使用

COPYFLG_NO_OVERWRITE (0×00000010)

不覆蓋目標檔案中已存檔案

COPYFLG_NO_VERSION_DIALOG (0×00000020)

如果目標檔案已存且新則不覆蓋也不出現對話方塊

COPYFLG_REPLACEONLY (0×00000040)

替換目標檔案

[delete Registry] 描述如何增加註冊表項目。 del -registry-section 節名必須處現在 install 節中的 DelReg 條目中。

[del-registry-section]

reg-root-string, [subkey], [value-name], [flags], [value]

[reg-root-string, [subkey], [value-name], [flags], [value]]

reg-root-string 註冊表的根名:

HKCR HKEY_CLASSES_ROOT.

HKCU HKEY_CURRENT_USER.

HKLM HKEY_LOCAL_MACHINE.

HKU HKEY_USERS.

HKR 相關於 SetupInstallFromInfSection. 節中指定的值

subkey

value-name

可選,標示 subkey 的值名稱。對於字串類型可以空,標示預設字串值

[Delete Files] 此節指定需要被刪除的檔案 , 節名必須出現在 install 中的 delfiles 條目中

[file-list-section]

file-name[,,,flag]

flag

可選。

DELFLG_IN_USE (0×00000001)

當因為檔案正被使用, SetupCommitFileQueue 取消 , 將排隊在系統重新啟動時候被刪除。

如果不使用此值,則安裝時候被使用的檔案不會被 delete files 指定節刪除

DELFLG_IN_USE1 (0×00010000)

高位元組版本的 DELFLG_IN_USE. Setting DELFLG_IN_USE1 差別在於同樣可適用於 Copyfiles 節和 delete Files 節即使 COPYFLG_WARN_IF_SKIP 標誌被使用。

[INI File to Registry] 此節指示那些 ini 檔案中的條目將對應到註冊表。

[ini-to-registry-section]

ini-file, ini-section, [ini-key],reg-root-string,subkey[,flags]

ini-file

ini 檔案名稱 .

ini-section

ini 檔案的節

ini-key

條目

flags

指示當註冊表存在對應的登錄機碼目是否是否覆蓋舊值。

Bit value

0 0 預設,不刪除 ini 檔案項目,當 ini 轉移到註冊表後

0 1 刪除 ini 檔案中的項目,當 ini 轉移到註冊表後

1 0 預設,當註冊表存在此子項,則不覆蓋

1 1 覆蓋

[Rename Files] 此類型節列出那些將樣改名的檔案。此節名必須出現在 install 節中

[rename-files-section-name]

new-file-name,old-file-name

new-file-name

新檔案名稱

old-file-name

原來的檔案名稱。此參數必須定義於 SourceDisksFiles 節中。

[Update INI Fields] 此節替換、增加、刪除指定 ini 檔案的條目。此節名必須存在於 install 節中。

[update-inifields-section-name]

ini-file,ini-section,profile-name,[old-field],[new-field],[flags]

參數說明見上

[Update INI File] 此節刪除、替換或者新增 INI 的項目 . 節名必須處現在 install 節中的 UpdateInis 條目中

update-ini-section-name]

ini-file,ini-section,[old-ini-entry],[new-ini-entry],[flags]

ini-file

包含將要改變的條目的 ini 檔案。

ini-section

節名

old-ini-entry

可選的,通常為 key=value 形式

new-ini-entry

可選。通常來自 key=value. key 或者 value 可以為可替換的字串。

flags

可選命令標誌 .

Value Meaning

0 預設。如果 old-ini-entry key 出現在 INI file 條目中 , 將被 new-ini-entry 替換。 值會被忽略,只要 key 匹配即可。為無條件增加新條目到 ini 檔案,可設定 old-ini-entry 為 NULL 。 為無條件從 ini 檔案中刪除 old-ini-entry from ,設定 new-ini-entry 為 NULL 。

1 如果 old-ini-entry 的 key 和 value 已經存在於 INI 檔案 , 將被 new-ini-entry 替換。 old-ini-entry 參數的 key 和 value 都必須匹配

2 如果 old-ini-entry 參數沒有出現在 INI 檔案中 , 將不進行任何替換

若 old-ini-entry 的 key 存在於 INI 檔案且 new-ini-entry 的 key 存在於 INI 檔案 , INI 檔案中匹配的 new-ini-entry 的 key 參數被刪除 , old-ini-entry 的 key 匹配參數被替換

3 類似 2 ,但是,例外情況為: old-ini-entry 參數匹配基於 key 和 value, 並不限於 key

可以使用萬用字元 (*) 指代 key 和 value 的一部分和全部

ini 檔案名稱可以為字串或者字元鍵。即 %strkey% ,此 strkey 定義於 [Strings] 節,且必須是一個合法檔案名稱。

Ini 檔案明應當包含目錄,可以是直接目錄,也可以是特定目錄標示符。

可以擁有 %dirid% 指定目錄, dirid 指定於 SetupSetDirectoryId 節中 . 當時用目錄標示符,你應當使用反斜線於一個目錄路徑中。舉例: , 你可以使用 %11%\card.ini 表示 CARD.INI 存在於 System32 目錄中。

以下為例子:

%11%\sample.ini, Section1,, Value1=2 ; 新增一個條目

%11%\sample.ini, Section2, Value3=*, ; 刪除老條目

%11%\sample.ini, Section4, Value5=1, Value5=4 ; 替換老條目

[Services] 條目 此節條目列出增加和刪除的服務列表。

[install-section-name.Services]

AddService=ServiceName,flag,service-install-section[,event-log-install-section]

DelService=ServiceName

ServiceName

將要安裝 / 刪除的服務名

flag

指定將如何增加服務。此參數僅用於 AddService 鍵,取值為:

SPSVCINST_TAGTOFRONT (0×1)

將服務標籤題見到服務所在組的前列

SPSVCINST_ASSOCSERVICE (0×2)

此增加的服務關聯的服務 .

service-install-section

服務安裝節

event-log-install-section

時間記錄安裝節。

以下為例子:

[Ser_Inst.Services]

AddService = sermouse, 0×00000002, sermouse_Service_Inst, sermouse_EventLog_Inst ; Port Driver

AddService = mouclass,, mouclass_Service_Inst, mouclass_EventLog_Inst

; Class Driver

[Service Install] 此節列出將要安裝的每一個服務資訊

[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

驅動類型。為任何被 theCreateService 函數認可的參數。

start-code

何時啟動驅動程式。可為:

SERVICE_BOOT_START (0×0)

由作業系統 loader 啟動。使用此值僅用於作業系統基本服務。

SERVICE_SYSTEM_START (0×1)

作業系統初始化式啟動。

SERVICE_AUTO_START (0×2)

SCM 在系統啟動期間啟動

SERVICE_DEMAND_START (0×3)

SCM 根據需要啟動

SERVICE_DISABLED (0×4)

此服務不可被啟動

error-control-level

指定錯誤控制層級。

CRITICAL (0×3)

如果驅動裝載失敗,啟動失敗。如果啟動不是在 “最後一次正確( LastKnownGood. )”控制集,切換到 LastKnownGood 。如果啟動試圖用於 LastKnownGood, 運行故障檢查常式

SEVERE (0×2)

如果啟動不是用於 LastKnownGood , 切換到 LastKnownGood 。如果啟動試圖 LastKnownGood, 發生錯誤時繼續啟動。

NORMAL (0×1)

若初始化時失敗,啟動將繼續,但顯示警告資訊

IGNORE (0×0)

若初始化時失敗,啟動將繼續,無警告資訊

path

二進位檔案路徑

load-order-group-name

可選 . 指示服務處在的服務組中的次序 : pointer, port, primary disk, and so forth.

+depend-on-group-name

可選,服務依賴的服務組,服務僅當該組的最後一個服務都啟動後才啟動

depend-on-service-name

可選。依賴的服務。

driver-object-name

可選。如果類型屬於 Kernel driver 或者 file system driver, ,此名用於 I/O 管理器裝載的名稱

例子:

[mouclass_Service_Inst]

DisplayName = %mouclass.SvcDesc%

ServiceType = 1 ; SERVICE_KERNEL_DRIVER

StartType = 1 ; SERVICE_SYSTEM_START

ErrorControl = 1 ; SERVICE_ERROR_NORMAL

ServiceBinary = %12%\mouclass.sys

LoadOrderGroup = Pointer Class

[DestinationDirs] 此節用於指定( copy file ,rename file 等節中的目標目錄)

[DestinationDirs]

file-list-section=drid[,subdir]

. .

[DefaultDestDir=drid[,subdir]]

file-list-section

Copy Files, Rename Files, 或者 Delete Files 節名 . drid

目錄標示 (DRID) 。 安裝程式在安裝期間替換一個 DIRID 採用實際的目錄

DIRID %dirid% 為預先定義的目錄

DIRID 可為以下值:

-01,0xffff 目錄

01 SourceDrive:\path.

10 Windows directory.

11 System directory. (%windir%\system on Windows 95, %windir%\system32 on Windows NT)

12 Drivers directory.(%windir%\system32\drivers on Windows NT)

17 INF 檔案目錄

18 help 目錄

20 Fonts directory.

21 察看器目錄

24 應用程式目錄

25 共用目錄 Shared directory.

30 開機磁碟機的根目錄 Root directory of the boot drive.

50 %windir%\system

51 假離線目錄 Spool directory.

52 Spool drivers directory.

53 使用者 Profile 目錄

54 ntldr or OSLOADER.EXE 所在目錄

subdir

子目錄名

可選項 DefaultDestDir 提供預設的目標目錄。如果 DefaultDestDir 未用於 DestinationDirs 節,預設的目錄設為 drid_system.

[SourceDisksFiles] 此節指定源安裝盤上的檔案

為了允許多作業系統分發源檔案,你可構造針對特定平台的 SourceDisksFiles 節舉例來講, 在 MIPS 平台上,所有安裝功能在用到 SourceDisksFiles 節將首先尋找 SourceDisksFiles.Mips 節。 如果安裝功能未找到 SourceDisksFiles.Mips 節 , 或者某個特定行未能在那裡找到,安裝功能將使用 SourceDisksFiles 節。此行為直接或間接影響安裝功能處理 SourceDisksFiles 節作為其進程的一部分。

大小寫不敏感的首碼可為:

alpha

mips

ppc

x86

[SourceDisksFiles]

filename=disk-number[,subdir][,size]

filename

在源此盤上的檔案名稱

disk-number

第幾號來源硬碟包含此檔案。大於等於 1 ,且定義於 SourceDisksNames 節

subdir

選擇性參數。在來源硬碟上的子目錄,預設為來源硬碟的跟目錄

size

選擇性參數,檔案的壓縮尺寸

[SourceDisksFiles]

SRS01.x86 = 1 ;源檔案 SRS01.x86 存在於安裝盤一號盤的根目錄

[SourceDisksNames] 指示源檔案的磁碟名稱

為了允許多作業系統分發源檔案,你可構造針對特定平台的 SourceDisksNames 節舉例來講, 在 MIPS 平台上,所有安裝功能在用到 SourceDisksNames 節將首先尋找 SourceDisksNames.Mips 節。 如果安裝功能未找到 SourceDisksNames.Mips 節 , 或者某個特定行未能在那裡找到,安裝功能將使用 SourceDisksNames 節。此行為直接或間接影響安裝功能處理 SourceDisksNames 節作為其進程的一部分。

大小寫不敏感的首碼可為:

alpha

mips

ppc

x86

[SourceDisksNames[.platform]]

disk-ordinal=”disk-description”[,[disk-label],[unused,path]

.

platform

指示源檔案應用的平台指示符。

disk-ordinal

磁碟序號

disk-description

“”包含的字串,用於標示磁碟。

disk-label

磁碟卷標

unused

保留未用

path

選擇性參數,源檔案的絕對路徑,如果未用,則表示示根目錄

如下例子中, write.exe 所有平台都一樣,且存在於來源硬碟 1 的 \common 目錄。圓盤 1 將所有平台都一致的檔案存在於 \common 目錄中。 CMD.EXE 檔案特定於平台,磁碟 2 指示安裝功能針對每一個平台的特定目錄。 HALNECMP.DLL 檔案特定於 MIPS 平台。

[SourceDisksNames]

1 = “Windows NT CD-ROM”, Instd1,, \common

[SourceDisksNames.Alpha]

2 = “Windows NT CD-ROM”, Instd1,, \alpha

[SourceDisksNames.Mips]

2 = “Windows NT CD-ROM”, Instd1,, \mips

[SourceDisksNames.x86]

2 = “Windows NT CD-ROM”, Instd1,, \x86

[SourceDisksNames.ppc]

2 = “Windows NT CD-ROM”, Instd1,, \ppc

[SourceDisksFiles]

write.exe = 1

cmd.exe = 2

[SourceDisksFiles.Mips]

halnecmp.dll = 2

[EventLog Install] 該節往註冊表中加入事件訊息檔案,也可利用此節移除事件訊息檔案。

[install-section-name_EventLogInstallSection]

AddReg=add-registry-section

DelReg=del-registry-section

add-registry-section

del-registry-section

事件訊息節名

AddReg 指示哪節將作為增加事件的登錄機碼

DelReg 指示刪除事件項

以下為典型的 EventLog 安裝節:

[sermouse_EventLog_Inst]

AddReg=sermouse_EventLog_AddReg

[sermouse_EventLog_AddReg]

HKR,EventMessageFile,0×00020000,”%%SystemRoot%%\System32\IoLogMsg.dll\;%%SystemRoot%%\System32\drivers\sermouse.sys”

HKR,,TypesSupported,0×00010001,7

[Strings] 該節定義了 1 個或多個字串關鍵字 . 一個字串 key 展開一個可列印字串

可以有針對特定語言的 String 節

[Strings[.langid]]

strings-key=value

langid

可選的指示 string 節所屬語言的語言標示符 . 舉例 , U.S. English 是 0409 以及 Standard French 是 040c.

strings-key

由字元和數字組成的唯一名符

value

展開後的字串內容

例子:

[Strings]

String0=”Corporation X”

String1=”Corporation X”

String2=”CS2590 SCSI Adapter”

特定語言的例子:

[Strings.0409]

; American English strings

S1 = “Hello”

[Strings.0009]

; British English strings

; Note that 0009 is used instead of 0809 to make this the default

; for English languages other than U.S. English.

S1 = “Greetings”

[Strings]

; French strings

; Not specifying a langid makes this the default

S1 = “Bonjour”

注釋

儘管此節通常處於 inf 檔案的最後一節,但是定義的字串 Key 可用於 inf 檔案任何位置。安裝程式將展開字串

如果用到 %, 請使用 %% 。

Windows 95: 不可包含 strings 節,不支援多語言 .

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.