Python 如何从MSI文件中获取[二进制数据]值

Python 如何从MSI文件中获取[二进制数据]值,python,windows-installer,binary-data,Python,Windows Installer,Binary Data,我正在使用python msilib库读取MSI文件。我的目标是从二进制表中提取[二进制数据]并转储到文件中。使用ORCA工具,我们可以通过双击[binary data]单元格并写入文件来提取二进制数据 我找不到任何msilib方法来获取二进制数据。它具有使用Record.GetStringfield获取字符串数据的方法。但正如预期的那样,这对[二进制数据]不起作用,并给出错误 下面是代码片段 import msilib # msi file path which is to be read m

我正在使用python msilib库读取MSI文件。我的目标是从二进制表中提取[二进制数据]并转储到文件中。使用ORCA工具,我们可以通过双击[binary data]单元格并写入文件来提取二进制数据

我找不到任何msilib方法来获取二进制数据。它具有使用Record.GetStringfield获取字符串数据的方法。但正如预期的那样,这对[二进制数据]不起作用,并给出错误

下面是代码片段

import msilib
# msi file path which is to be read
msiFilePath = "C:/msi/test.msi"
dbObj = msilib.OpenDatabase(msiFilePath, msilib.MSIDBOPEN_READONLY)
sqlQuery = "select * from Binary"
view = dbObj.OpenView(sqlQuery)
view.Execute(None)
cur_record = viewObj.Fetch()
# In Binary table; Column no 1 have string data and Column # 2 have [Binary Data]
cur_record.GetString(2)
执行时:-

Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
cur_record.GetString(2)
_msi.MSIError: unknown error 70c
有什么办法吗?

是的。具体来说,它不能读取二进制数据

Pygame拥有更全面的功能和可扩展性,因为它是用Python和ctypes编写的。pygame文档中似乎没有介绍它,但是源代码非常简单


您需要的MSI API是MsiRecordReadStream,pygame.msidb将其包装在其游标类使用的get_field_stream中。

@Abery,还有什么我可以做的来让您更容易接受这个答案吗?