開啟 INF 檔案之後,您可以從中收集資訊以建置使用者介面,或指示安裝程式。 安裝程式函式提供數個層級的功能,可從 INF 檔案收集資訊。
| 若要收集資訊... | 使用這些函式... |
|---|---|
| 關於 INF 檔案 | SetupGetInfInformation |
| SetupQueryInfFileInformation | |
| SetupQueryInfVersionInformation。 | |
| 關於來源和目標檔案 | SetupGetSourceFileLocation |
| SetupGetSourceFileSize | |
| SetupGetTargetPath | |
| SetupGetSourceInfo | |
| 從 INF 檔案的一行 | SetupGetLineText |
| SetupFindNextLine | |
| SetupFindNextMatchLine | |
| SetupGetLineByIndex | |
| SetupFindFirstLine | |
| 從 INF 檔案中一行的欄位 | SetupGetStringField |
| SetupGetIntField | |
| SetupGetBinaryField | |
| SetupGetMultiSzField |
下列範例會使用 SetupGetSourceInfo 函式,從 INF 檔案擷取來源媒體的人類可讀取描述。
#include <windows.h>
#include <setupapi.h>
BOOL test;
HINF MyInf;
UINT SourceId;
PTSTR Buffer;
DWORD MaxBufSize;
DWORD BufSize;
int main()
{
test = SetupGetSourceInfo (
MyInf, //Handle to the INF file to access
SourceId, //Id of the source media
SRCINFO_DESCRIPTION, //which information to retrieve
Buffer, //a pointer to the buffer to receive the information
MaxBufSize, //the size allocated for the buffer
&BufSize //buffer size actually needed
);
return 0;
}
在此範例中,MyInf 是開啟 INF 檔案的控制碼。 SourceId 是特定來源媒體的識別碼。 值SRCINFO_DESCRIPTION指定 SetupGetSourceInfo 函式應該擷取來源媒體描述。 緩衝區會指向將接收描述的字串,MaxBufSize 表示配置給緩衝區的資源,BufSize 表示儲存緩衝區所需的資源。
如果 BufSize 大於 MaxBufSize,則函式會傳回 FALSE,而 GetLastError 的後續呼叫將會傳回ERROR_INSUFFICIENT_BUFFER。