[python-win32] Problem with COM Interface. Windows Installer
Peter Mott
peter at monicol.co.uk
Tue Oct 7 05:51:07 EDT 2003
The COM inteface apparently breaks when attempting to use "record" objects
derived from Windows.Installer.
Below is a sample script with comments:
import win32com.client
import os
import sys
msiOpenDatabaseModeReadOnly=0
msidb = "sample.msi"
installer = win32com.client.Dispatch("WindowsInstaller.Installer")
database = installer.OpenDatabase(msidb, msiOpenDatabaseModeReadOnly)
view = database.OpenView("SELECT File, FileName FROM File")
view.Execute()
record = view.Fetch()
x = record.FieldCount
print "%d fields" % x
# Everything to this point is fine. The print statement prints '2' as it
# should
# (1) This does not work. Trace follows:
x = record.DataSize(1)
# Attempting to get the DataSize gets this error.
##Traceback (most recent call last):
## File "C:\home\clients\SIMproject\SIM_INSTALL\BuildScripts\testinst.py", line
17, in -toplevel-
## x = record.DataSize(1)
## File "<COMObject <unknown>>", line 2, in DataSize
##com_error: (-2147352573, 'Member not found.', None, None)
# (2) This does not work with trace following
x = record.StringData(1)
##
##Traceback (most recent call last):
## File "C:\home\clients\SIMproject\SIM_INSTALL\BuildScripts\testinst.py", line
14, in -toplevel-
## x = record.StringData(1)
## File "<COMObject <unknown>>", line 2, in StringData
##com_error: (-2147352573, 'Member not found.', None, None)
-----------------
These lines are from a corresponding vbscript which works without
problem.
fileId = record.stringData(1)
filename= record.stringData(2)
I'm using W2K version 5.00. Python is 2.3.1 and w32all is build 157. The same
problem is on 155. Windows Installer is version 2.00.2600.1183.
I traced some of the Python code. It tries to find out what sort of 'object' it
is looking for, can't, tries a method as a last resort but enjoys no success.
I certainly do not know enough about COM to make any headway with this.
Thanks for any help
Peter
More information about the Python-win32
mailing list