Problem setting COM property using win32com

Green, Gregory P gregory.p.green at boeing.com
Mon Apr 7 17:03:04 EDT 2003


EnsureModule doesn't do the trick.

Here is what I have:

from win32com.client.gencache import EnsureModule
MyModule = EnsureModule('{C85E7012-8B4F-11D1-8E20-00A02498EA3C}', 0, 1, 0)

That loads the module but it doesn't help. I'll show the relevant portions of the genpy module:

class ISmRecordList(DispatchBaseClass):
	"""An object used for storing data. A collection of headers and records, each composed of a collection of nodes.  In turn, each node can contain information of various types."""
	CLSID = pythoncom.MakeIID('{C85E7013-8B4F-11D1-8E20-00A02498EA3C}')

# This CoClass is known by the name 'SmRecList.SmRecordList'
class SmRecordList(CoClassBaseClass): # A CoClass
	# An object used for storing data. A collection of headers and records, each composed of a collection of nodes.  In turn, each node can contain information of various types.
	CLSID = pythoncom.MakeIID("{C85E7014-8B4F-11D1-8E20-00A02498EA3C}")
	coclass_sources = [
	]
	coclass_interfaces = [
		'{C85E7013-8B4F-11D1-8E20-00A02498EA3C}',
		'{C85E7015-8B4F-11D1-8E20-00A02498EA3C}',
	]
	default_interface = '{C85E7013-8B4F-11D1-8E20-00A02498EA3C}'

-----Original Message-----
From: Paul Prescod [mailto:paul at prescod.net]
Sent: Monday, April 07, 2003 1:34 PM
To: Green, Gregory P
Cc: python-list at python.org
Subject: Re: Problem setting COM property using win32com


I don't know why that's happening, but I would suggest you take more 
control of the instantiation by doing something like this:

from win32com.client.gencache import EnsureModule
MyModule = EnsureModule('{3BBEE982-742B-11D2-BD0A-00A024C36143}', 0, 1, 0)

reclist = MyModule.SmRecList()

In my recent COM project, I used the "dispatch" mechanism and pythoncom 
was smart enough to pick up my gen_py'd module. But the mechanism above 
is fine too. In fact, it is probably better by virtue of being more 
explicit...

Green, Gregory P wrote:
> I don't think the gen_py class is being used:
> 
> print obj: <COMObject SmRecList.SmRecordList>
> 
> print obj.__class__: win32com.client.CDispatch
> 
> print dir(obj): ['_ApplyTypes_', '_LazyAddAttr_', '_NewEnum', '_Release_', '__AttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__', '__getattr__', '__getitem__', '__init__', '__int__', '__len__', '__module__', '__nonzero__', '__repr__', '__setattr__', '__setitem__', '__str__', '_builtMethods_', '_enum_', '_find_dispatch_type_', '_get_good_object_', '_get_good_single_object_', '_lazydata_', '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_']







More information about the Python-list mailing list