List Info

Thread: how to get the interface of an COM object?




how to get the interface of an COM object?
user name
2006-11-14 05:23:15
Hi, all

I am trying to use win32com to interact with a proprietary
COM object.
progID of the coclass is "SomeObj2.SomeObj.1", I
can create the
coclass but am not able to access other interfaces via
win32com.client.CastTo().

For example ISomeInterface is one of this COM object's
interfaces. But
no classes are generated for this interface in the file made
by
makepy.py. I can only find things like this:

ISomeInterface_vtables_dispatch_, ISomeInterface_vtables_

this is my code:

    te =
win32com.client.Dispatch("SomeObj2.SomeObj.1")
    # fail! Error message is:
    # ...
    # return mapCLSIDToClass[clsid]
    # KeyError: ''
    ISomeInterface_ = win32com.client.CastTo(te,
'ISomeInterface')


in the file generated by makepy.py, the class is very
simple:

class SomeObj(CoClassBaseClass): # A CoClass
	CLSID = IID('')
	coclass_sources = [
		_SomeObjEvents2,
		_SomeObjEvents,
		_SomeObjEvents4,
		_SomeObjEvents5,
		_SomeObjEvents3,
	]
	default_source = _SomeObjEvents5
	coclass_interfaces = [
	]

I googled the web and find some old posts in this maillist,
it seems
that only interfaces inherit from IDispatch can be used by
pythonCOM,
and interfaces here inherits from IUnknown. But I just need
to use
these interfaces, so could anybody tell me how to do it?

And this control and its interfaces are all available to
VBScript or
Visual Bacis:

   Set ISomeInterface_ =
SomeObj.interface("ISomeInterface")
   ...
   <OBJECT ID="SomeObj"
CLASSID="CLSID:7A4F5191-68A8-14D5-82C1-0001083952C1&quo
t; ></OBJECT>

Since VBScript and python are both script languages, I guess
python
can also access these interfaces.

Any help would be appreciated!

Bruce
_______________________________________________
Python-win32 mailing list
Python-win32python.org

http://mail.python.org/mailman/listinfo/python-win32
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )