LoadPDF在 Configuration Manager 中,Windows Management Instrumentation (WMI) 類別方法會將指定的套件定義檔案匯入套件定義檔案存放區。
下列語法是從 [受控物件格式] 簡化而 (MOF) 程式碼,並定義方法。
語法
SInt32 LoadPDF(
String PDFFileName,
String PDFFile,
UInt32 PDFID,
String RequiredIconNames[]
);
參數
PDFFileName 資料類型: String
限定詞:[in,SizeLimit (“100”) ]
套件定義檔案的完整路徑和檔案名稱。 SMS 提供者會將檔案複製到 \Smsinstalldir\Scripts\<localeid>\Pdfstore\<pdfid> 目錄,並將 .pdf 副檔名取代為 .sms 副檔名。
PDFFile 資料類型: String
限定詞:[in]
套件定義檔案本身的文字。
PDFID 資料類型: UInt32
資格賽:[出局]
指派的套件定義檔案識別碼。
RequiredIconNames 資料類型: String 陣列
資格賽:[出局]
套件定義檔案所參考的圖示清單,必須透過 類別 SMS_PDF_Package 方法中的 LoadIconForPDF 方法 個別載入。
傳回值
SInt32表示 0 表示成功或下列其中一個位元欄位警告旗標表示失敗的資料類型。
| 標幟 | 描述 |
|---|---|
| WARN_BAD_RUN (0) | 指定的執行資訊無效。 |
| WARN_BAD_RESTART (1) | 指定的重新啟動資訊無效。 |
| WARN_BAD_CANRUNWHEN (2) | 指定的 CanRunWhen 資訊無效。 |
| WARN_BAD_ASSIGNMENT (3) | 指定的作業資訊無效。 |
| WARN_BAD_DEPENDPROG (4) | 指定的 DependentProgram 資訊無效。 |
| WARN_BAD_SPECIFYDRIVE (5) | 指定的 SpecifyDrive 資訊無效。 |
| WARN_BAD_ESTDISKSPACE (6) | 指定的 EstimatedDiskSpace 資訊無效。 |
| WARN_NO_SUPPCLINFO (7) | 未指定 SupportedClients 資訊。 |
| WARN_BAD_SUPPCLINFO (8) | 指定的 SupportedClients 資訊無效。 |
| WARN_VER1PDF (9) | 使用1.0版檔案。 |
| WARN_REMPRONOUKEY (10) | 已設定移除程式,但未提供解除安裝金鑰。 |
註解
當您的應用程式匯入的套件定義檔案與現有套件定義檔案具有相同的 Name、 VersionPublisher及Language屬性時,會覆寫現有的套件定義檔案,包括檔案圖示和程式。 系統會保留參數中 PDFID 指定的值。
範例程式碼
下列範例顯示如何將套件定義檔案載入套件定義檔案套件存放區。
Const ForReading = 1
Dim fs, f ' File system object and file object.
Dim clsPDF As SWbemObject ' SMS_PDF_Package class definition.
Dim ReturnCode As Long ' Return code value from LoadPDF method.
Dim PDFID As Long ' Package definition file identifier generated from LoadPDF.
Dim PDFContent As String ' Package definition file file content.
Dim ReqIconNames() As Variant ' Required icon names from LoadPDF.
Dim Icon() As Byte ' Icon used as input to LoadIconForPDF method.
Dim i, j As Integer
Dim FileSize As Integer ' Size of the icon file.
Set Services = GetObject("winmgmts:\root\sms\<sitecode>")
' Open the package definition file file and read the content into a string.
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(<path\filename>, ForReading)
PDFContent = f.ReadAll
f.Close
' Load the package definition file into the package definition file store. Use the PDFID and ReqIconNames
' Variables in the LoadIconForPDF method.
Set clsPDF = Services.Get("SMS_PDF_Package")
ReturnCode = clsPDF.LoadPDF(<path\filename>, _
PDFContent, _
PDFID, _
ReqIconNames)
' You must load all the icons for the package definition file if the package definition file contains icons.
For i = LBound(ReqIconNames) To UBound(ReqIconNames)
Open <path> & ReqIconNames(i) For Binary Access Read As #1
FileSize = LOF(1) - 1
ReDim Icon(FileSize)
For j = 0 To FileSize
Get #1, , Icon(j)
Next
Close #1
clsPDF.LoadIconForPDF PDFID, ReqIconNames(i), Icon
Next
需求
執行階段需求
如需詳細資訊,請參閱 Configuration Manager 伺服器執行階段需求。
開發需求
如需詳細資訊,請參閱 Configuration Manager 伺服器開發需求。