[python-win32] how to get the interface of an COM object?

Mark Hammond mhammond at skippinet.com.au
Tue Nov 14 06:43:11 CET 2006


> 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?

I'm afraid that what you googled is still correct - only interfaces
implemented using IDispatch can be called by pywin32.

> 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" ></OBJECT>
>
> Since VBScript and python are both script languages, I guess python
> can also access these interfaces.

VB can use all interfaces, but I believe VBScript can not.  Can you show me
some VBScript code that runs under the Windows Scripting Host (WSH - ie,
wscript.exe/cscript.exe) that does what you need?

Cheers,

Mark



More information about the Python-win32 mailing list