SMS_PDF_Package 类中的 LoadPDF 方法

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

限定符:[out]

分配的包定义文件 ID。

RequiredIconNames 数据类型: String 数组

限定符:[out]

包定义文件引用的图标列表,必须通过 类SMS_PDF_Package方法中的 LoadIconForPDF 方法 单独加载这些图标。

返回值

一种 SInt32 数据类型,指示 0 表示成功,以下位域警告标志之一表示失败。

Flag 说明
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、 、 PublisherVersion和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 服务器开发要求。

另请参阅

SMS_PDF_Package服务器 WMI 类