Pkg.MSI — API for parsing MSI files

Overview

The Pkg.MSI module contains the API for parsing Windows Installer (MSI) files.

Parsing an MSI File

The following code example demonstrates how to parse an MSI file and list its tables:

from Pro.Core import *
from Pkg.MSI import *

def parseMSI(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = MSIObject()
    if not obj.Load(c) or not obj.Initialize():
        return
    # list all tables
    for name in obj.GetTableNames():
        print("table:", name)
    # read a specific table
    table = obj.GetTable("File")
    if table is None:
        return
    cols = obj.GetTableColumnNames(table)
    n = obj.GetTableRowCount(table)
    for r in range(n):
        row = obj.GetTableRow(table, r)
        if row is not None:
            print(row)

Retrieving Summary Information

The following code example demonstrates how to retrieve summary information:

from Pro.Core import *
from Pkg.MSI import *

def printMSISummary(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = MSIObject()
    if not obj.Load(c) or not obj.Initialize():
        return
    print("title:", obj.GetSummaryTitle())
    print("subject:", obj.GetSummarySubject())
    print("author:", obj.GetSummaryAuthor())
    print("arch:", obj.GetSummaryArch())
    print("app:", obj.GetSummaryCreatingApplication())
    print("uuid:", obj.GetSummaryUUID())
    print("comments:", obj.GetSummaryComments())

Module API

Pkg.MSI module API.

Classes:

MSIObject()

This class represents an MSI (Windows Installer) file.

class MSIObject

Bases: Pro.Core.CFFObject

This class represents an MSI (Windows Installer) file.

Methods:

GetSummaryArch()

Retrieves the architecture (e.g., “Intel”, “x64”) from the MSI summary information.

GetSummaryAuthor()

Retrieves the author from the MSI summary information.

GetSummaryComments()

Retrieves the comments from the MSI summary information.

GetSummaryCreatingApplication()

Retrieves the name of the application that created the MSI file.

GetSummarySubject()

Retrieves the subject from the MSI summary information.

GetSummaryTitle()

Retrieves the title from the MSI summary information.

GetSummaryUUID()

Retrieves the UUID from the MSI summary information.

GetTable(name)

Retrieves a table by name.

GetTableColumnNames(table)

Retrieves the column names of a table.

GetTableNames()

Retrieves the sorted list of table names in the MSI file.

GetTableRow(table, row)

Retrieves a row from a table as a dictionary mapping column names to values.

GetTableRowCount(table)

Retrieves the number of rows in a table.

GetSummaryArch()Optional[str]

Retrieves the architecture (e.g., “Intel”, “x64”) from the MSI summary information.

Returns

Returns the architecture string if available; otherwise returns None.

Return type

Optional[str]

GetSummaryAuthor()Optional[str]

Retrieves the author from the MSI summary information.

Returns

Returns the author if available; otherwise returns None.

Return type

Optional[str]

GetSummaryComments()Optional[str]

Retrieves the comments from the MSI summary information.

Returns

Returns the comments if available; otherwise returns None.

Return type

Optional[str]

GetSummaryCreatingApplication()Optional[str]

Retrieves the name of the application that created the MSI file.

Returns

Returns the application name if available; otherwise returns None.

Return type

Optional[str]

GetSummarySubject()Optional[str]

Retrieves the subject from the MSI summary information.

Returns

Returns the subject if available; otherwise returns None.

Return type

Optional[str]

GetSummaryTitle()Optional[str]

Retrieves the title from the MSI summary information.

Returns

Returns the title if available; otherwise returns None.

Return type

Optional[str]

GetSummaryUUID()Optional[str]

Retrieves the UUID from the MSI summary information.

Returns

Returns the UUID string if available; otherwise returns None.

Return type

Optional[str]

GetTable(name: str)Any

Retrieves a table by name. The table rows are loaded on demand.

Parameters

name (str) – The table name.

Returns

Returns the table if successful; otherwise returns None.

See also GetTableNames(), GetTableColumnNames(), GetTableRowCount() and GetTableRow().

GetTableColumnNames(table: Any)List[str]

Retrieves the column names of a table.

Parameters

table (Any) – The table returned by GetTable().

Returns

Returns a list of column names.

Return type

List[str]

See also GetTable().

GetTableNames()List[str]

Retrieves the sorted list of table names in the MSI file.

Returns

Returns a list of table names.

Return type

List[str]

GetTableRow(table: Any, row: int)Optional[Dict[str, Optional[Union[int, float, bool, bytes, str]]]]

Retrieves a row from a table as a dictionary mapping column names to values.

Parameters
  • table (Any) – The table returned by GetTable().

  • row (int) – The row index.

Returns

Returns a dictionary containing the row data if successful; otherwise returns None.

Return type

Optional[Dict[str, BasicType]]

See also GetTable() and GetTableRowCount().

GetTableRowCount(table: Any)int

Retrieves the number of rows in a table.

Parameters

table (Any) – The table returned by GetTable().

Returns

Returns the number of rows.

Return type

int

See also GetTable() and GetTableRow().