'Member not found.' problem with win32com.client.

Peter Haight peterh at sapros.com
Mon Jul 9 02:30:52 CEST 2001


I'm trying to use the automation interface to the Windows Installer stuff
and am having a problem. I used 'makepy.py' on 'Microsoft Windows Installer
Object Library (1.0)' which created a nice interface file, but it doesn't
quite work.

First of all, it looks like the COM object doesn't support GetTypeInfo so I
have to make the classes manually, but I'm also getting a 'Member not
found.' error when I call some methods.

I can kind of get around this by not using the wrapper module, but then I
was getting the same error for 'error.StringData(1)'. Now as you can see in
my work-around version, I can fix that by wrapping error.

Here's my code:
---------------
import shutil
import win32com.client
import win32com.client.gencache


template_installer_name = 'EmptyInstaller.msi'
project_installer_name = 'test.msi'

shutil.copy(template_installer_name, project_installer_name)
wininst = win32com.client.gencache.GetModuleForProgID("WindowsInstaller.Installer")
o = wininst.Installer(win32com.client.Dispatch("WindowsInstaller.Installer"))
db = o.OpenDatabase(project_installer_name, 
		    win32com.client.constants.msiOpenDatabaseModeTransact)
query_str = "select from Directory where DefaultDir = 'SourceDir' and Directory_Parent = ''"
try:
	view = db.OpenView(query_str)
except:
	error = o.LastErrorRecord()
	for field_num in range(1, error.FieldCount + 1):
		print error.StringData(field_num)
-------------

Here's the traceback I get when I run it:
-------------
Traceback (most recent call last):
  File "winstall.py", line 18, in ?
    error = o.LastErrorRecord()
  File "c:\programs\lang\python\win32com\gen_py\000C1092-0000-0000-C000-000000000046x1033x1x0.py", line 357, in LastErrorRecord
    ret = self._oleobj_.InvokeTypes(0xa, LCID, 1, (9, 0), (),)
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)

-------------

Here's the method in the generated module file:
-------------
	# Result is of type Record
	def LastErrorRecord(self):
		ret = self._oleobj_.InvokeTypes(0xa, LCID, 1, (9, 0), (),)
		if ret is not None: ret = win32com.client.Dispatch(ret, 'LastErrorRecord', '{000C1093-0000-0000-C000-000000000046}',
UnicodeToString=0)
		return ret

-------------

Here's how I'm working around it
-------------
import shutil
import win32com.client
import win32com.client.gencache


template_installer_name = 'EmptyInstaller.msi'
project_installer_name = 'test.msi'

shutil.copy(template_installer_name, project_installer_name)
wininst =
win32com.client.gencache.GetModuleForProgID("WindowsInstaller.Installer")
o = win32com.client.Dispatch("WindowsInstaller.Installer")
db = o.OpenDatabase(project_installer_name, 
		    win32com.client.constants.msiOpenDatabaseModeTransact)
query_str = "select from Directory where DefaultDir = 'SourceDir' and Directory_Parent = ''"
try:
	view = db.OpenView(query_str)
except:
	error = o.LastErrorRecord
	error = wininst.Record(error)
	for field_num in range(1, error.FieldCount + 1):
		print error.StringData(field_num)




More information about the Python-list mailing list