win32com - .ocx won't Dispatch...

Ray Schumacher rays at blue-cove.com
Thu Jan 29 19:03:59 EST 2004


Thanks Markus,

At 01:53 PM 1/29/2004, Markus Wankus wrote:
>Well - I have never seen "Catastrophic failure" before - but I have fought with win32com and know how frustrating it can be.  Also - I am NOT a COM guru - more of a trial and error guru ;o).

I'm a Jack-of-all-master-of-none Guru...

>Try the following:
>
>edr_mod = gencache.EnsureModule('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}',0,3,5) 
>
>edr_obj = Dispatch("EDREUTLX.EDREUtlXCtrl.1")
>
>edr_obj.AboutBox()

>>> from win32com.client import *
>>> edr_mod = gencache.EnsureModule('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}',0,3,5)
>>> edr_obj = Dispatch("EDREUTLX.EDREUtlXCtrl.1")
>>> edr_obj.AboutBox
<bound method _DEDREUtlX.AboutBox of <win32com.gen_py.EDRE Utility Control._DEDREUtlX instance at 0x10542896>>
>>> edr_obj.AboutBox()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python23\lib\site-packages\win32com\gen_py\8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5.py", line 34, in AboutBox
    return self._oleobj_.InvokeTypes(-552, LCID, 1, (24, 0), (),)
pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None)

Yep, the same. It sees the methods but fails when requesting them or properties.
A capture of the Python com Browser is attached, as well as the .py...

Thanks for your help, I did see one other post via Google about the issue, but it was not resolved.
Ray

>>From: Ray Schumacher 
>>To: Markus Wankus , python-list at python.org 
>>Subject: Re: win32com - .ocx won't Dispatch... 
>>Date: Thu, 29 Jan 2004 13:44:09 -0800 
>> 
>>At 12:12 PM 1/29/2004, Markus Wankus wrote: 
>> >Open the gen_py'd file 8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5.py, and do some searching.  You should be able to find an obvious main class related to what you are doing (I'm not sure what the .tlb is), and it will say in the comment or docstring that it is a ".", or whatever. 
>> 
>>Thanks Markus, 
>> 
>>The lines are from CoClassBaseClass: 
>>... 
>># This CoClass is known by the name 'EDREUTLX.EDREUtlXCtrl.1' 
>>class EDREUtlX(CoClassBaseClass): # A CoClass 
>>... 
>>That would be a helpful bit for the docs! 
>> 
>>So, the util class Dispatches, but all calls (properties and functions) give 'Catastrophic failure' 
>>Is this really some sort of types problem with this OCX? 
>>"pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None)" 
>> 
>>Thanks for the help, 
>>Ray 
>> 
>>Test run below, kitchen sink included: 
>> 
>>C:\projects\CV-Mini>python 
>>Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32 
>>Type "help", "copyright", "credits" or "license" for more information. 
>> >>> from win32com.client import * 
>> >>> util = gencache._GetModule('8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5') 
>> >>> gencache.GetGeneratedFileName('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA',0,3,5) 
>>'AA34F82-95C9-11D3-8EB6-00C0DF2247Cx0x3x5' 
>> >>> gencache.MakeModuleForTypelib('8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5',0 
>>,3,5) 
>> >>> gencache.GetModuleForCLSID('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA') 
>> >>> gencache.GetClassForCLSID('8AA34F82-95C9-11D3-8EB6-00C0DF2247CA') 
>> >>> gencache.GetModuleForProgID('EDREUTLX.EDREUtlXCtrl.1') 
>> 
>> >>> gencache.EnsureModule('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}',0,3,5) 
>> 
>> >>> gencache.EnsureModule('EDREUTLX.EDREUtlXCtrl.1',0,3,5) 
>> >>> util = Dispatch("EDREUTLX.EDREUtlXCtrl.1") 
>> >>> util 
>> 
>> >>> gencache.EnsureDispatch(util) 
>> 
>> >>> 
>> >>> util = Dispatch("EDREUTLX.EDREUtlXCtrl.1") 
>> >>> util 
>> 
>> >>> # pop-up, no args 
>>... util.AboutBox() 
>>Traceback (most recent call last): 
>>   File "", line 2, in ? 
>>   File "C:\Python23\lib\site-packages\win32com\gen_py\8AA34F82-95C9-11D3-8EB6-00 
>>C0DF2247CAx0x3x5.py", line 34, in AboutBox 
>>     return self._oleobj_.InvokeTypes(-552, LCID, 1, (24, 0), (),) 
>>pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) 
>> >>> # a property 
>>... util.Version 
>>Traceback (most recent call last): 
>>   File "", line 2, in ? 
>>   File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 451, in 
>>  __getattr__ 
>>     return self._ApplyTypes_(*args) 
>>   File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 445, in 
>>  _ApplyTypes_ 
>>     return self._get_good_object_(self._oleobj_.InvokeTypes(*((dispid, 0, wFlags 
>>, retType, argTypes) + args)), user, resultCLSID) 
>>pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) 
>> >>> 
>> 
>> 
>
>
>----------
>The new <http://g.msn.com/8HMBENCA/2737??PS=>MSN 8: smart spam protection and 2 months FREE* 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040129/0560c0b4/attachment.html>
-------------- next part --------------
# -*- coding: mbcs -*-
# Created by makepy.py version 0.4.8
# By python version 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)]
# From type library 'EDREUtlX.ocx'
# On Wed Jan 28 16:25:02 2004
"""EDRE Utility Control"""
makepy_version = '0.4.8'
python_version = 0x20303f0

import win32com.client.CLSIDToClass, pythoncom
import win32com.client.util
from pywintypes import IID
from win32com.client import Dispatch

# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing and pythoncom.Empty
defaultNamedOptArg=pythoncom.Empty
defaultNamedNotOptArg=pythoncom.Empty
defaultUnnamedArg=pythoncom.Empty

CLSID = IID('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}')
MajorVersion = 3
MinorVersion = 5
LibraryFlags = 10
LCID = 0x0

from win32com.client import DispatchBaseClass
class _DEDREUtlX(DispatchBaseClass):
	"""Dispatch interface for EDREUtlX Control"""
	CLSID = IID('{8AA34F83-95C9-11D3-8EB6-00C0DF2247CA}')
	coclass_clsid = IID('{8AA34F85-95C9-11D3-8EB6-00C0DF2247CA}')

	def AboutBox(self):
		return self._oleobj_.InvokeTypes(-552, LCID, 1, (24, 0), (),)

	def GetErrorName(self, ErrorCode=defaultNamedNotOptArg):
		# Result is a Unicode object - return as-is for this version of Python
		return self._oleobj_.InvokeTypes(13, LCID, 1, (8, 0), ((3, 0),),ErrorCode)

	def Query(self, QueryCode=defaultNamedNotOptArg, Param=defaultNamedNotOptArg):
		return self._oleobj_.InvokeTypes(14, LCID, 1, (3, 0), ((3, 0), (3, 0)),QueryCode, Param)

	def SelectDialog(self):
		return self._oleobj_.InvokeTypes(12, LCID, 1, (3, 0), (),)

	_prop_map_get_ = {
		"ADChannels": (6, 2, (3, 0), (), "ADChannels", None),
		"BoardName": (5, 2, (8, 0), (), "BoardName", None),
		"BoardType": (4, 2, (3, 0), (), "BoardType", None),
		"Counters": (11, 2, (3, 0), (), "Counters", None),
		"DAChannels": (7, 2, (3, 0), (), "DAChannels", None),
		"DIOPorts": (8, 2, (3, 0), (), "DIOPorts", None),
		"DriverVersion": (3, 2, (8, 0), (), "DriverVersion", None),
		"ManDate": (10, 2, (8, 0), (), "ManDate", None),
		"Revision": (9, 2, (3, 0), (), "Revision", None),
		"SerialNumber": (1, 2, (3, 0), (), "SerialNumber", None),
		"Version": (2, 2, (8, 0), (), "Version", None),
	}
	_prop_map_put_ = {
		"ADChannels" : ((6, LCID, 4, 0),()),
		"BoardName" : ((5, LCID, 4, 0),()),
		"BoardType" : ((4, LCID, 4, 0),()),
		"Counters" : ((11, LCID, 4, 0),()),
		"DAChannels" : ((7, LCID, 4, 0),()),
		"DIOPorts" : ((8, LCID, 4, 0),()),
		"DriverVersion" : ((3, LCID, 4, 0),()),
		"ManDate" : ((10, LCID, 4, 0),()),
		"Revision" : ((9, LCID, 4, 0),()),
		"SerialNumber" : ((1, LCID, 4, 0),()),
		"Version" : ((2, LCID, 4, 0),()),
	}

class _DEDREUtlXEvents:
	"""Event interface for EDREUtlX Control"""
	CLSID = CLSID_Sink = IID('{8AA34F84-95C9-11D3-8EB6-00C0DF2247CA}')
	coclass_clsid = IID('{8AA34F85-95C9-11D3-8EB6-00C0DF2247CA}')
	_public_methods_ = [] # For COM Server support
	_dispid_to_func_ = {
		}

	def __init__(self, oobj = None):
		if oobj is None:
			self._olecp = None
		else:
			import win32com.server.util
			from win32com.server.policy import EventHandlerPolicy
			cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer)
			cp=cpc.FindConnectionPoint(self.CLSID_Sink)
			cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy))
			self._olecp,self._olecp_cookie = cp,cookie
	def __del__(self):
		try:
			self.close()
		except pythoncom.com_error:
			pass
	def close(self):
		if self._olecp is not None:
			cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None
			cp.Unadvise(cookie)
	def _query_interface_(self, iid):
		import win32com.server.util
		if iid==self.CLSID_Sink: return win32com.server.util.wrap(self)

	# Event Handlers
	# If you create handlers, they should have the following prototypes:


from win32com.client import CoClassBaseClass
# This CoClass is known by the name 'EDREUTLX.EDREUtlXCtrl.1'
class EDREUtlX(CoClassBaseClass): # A CoClass
	# EDRE Utility Control
	CLSID = IID('{8AA34F85-95C9-11D3-8EB6-00C0DF2247CA}')
	coclass_sources = [
		_DEDREUtlXEvents,
	]
	default_source = _DEDREUtlXEvents
	coclass_interfaces = [
		_DEDREUtlX,
	]
	default_interface = _DEDREUtlX

RecordMap = {
}

CLSIDToClassMap = {
	'{8AA34F83-95C9-11D3-8EB6-00C0DF2247CA}' : _DEDREUtlX,
	'{8AA34F84-95C9-11D3-8EB6-00C0DF2247CA}' : _DEDREUtlXEvents,
	'{8AA34F85-95C9-11D3-8EB6-00C0DF2247CA}' : EDREUtlX,
}
CLSIDToPackageMap = {}
win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap )
VTablesToPackageMap = {}
VTablesToClassMap = {
}


NamesToIIDMap = {
	'_DEDREUtlX' : '{8AA34F83-95C9-11D3-8EB6-00C0DF2247CA}',
	'_DEDREUtlXEvents' : '{8AA34F84-95C9-11D3-8EB6-00C0DF2247CA}',
}




More information about the Python-list mailing list