[python-win32] Win32com , how select coclass interface?
Mark Hammond
mhammond at skippinet.com.au
Thu Oct 19 00:44:54 CEST 2006
> I have a DLL that have several interfaces accociated
> with a CoClass, but there is one default interface.
>
> snip from my genpy generated .py file:
> ------------------------------
> from win32com.client import CoClassBaseClass
> # This CoClass is known by the name
> 'BK.BasicEnv.Application.RemoteAPI'
> class RemoteAPI(CoClassBaseClass): # A CoClass
> CLSID = IID('{5BC25821-4936-4E9E-9ACF-12E12ADDA9CC}')
> coclass_sources = [
> ]
> coclass_interfaces = [
> I2250Instrument,
> IDisposable,
> I2250Control,
> IRemoteAPI,
> IRemoteInfo,
> I2250Connect,
> _Object,
> I2250Archive,
> I2250Export,
> ]
> default_interface = IRemoteAPI
> --------------------
> This is the result of usage:
> >>> import win32com.client
> >>> q =
> win32com.client.Dispatch("BK.BasicEnv.Application.RemoteAPI")
> >>> q
> <win32com.gen_py.Env Programming Interface.IRemoteAPI
> instance at 0x15301248>
It should be possible to use win32com.client.CastTo - something like:
q = win32com.client.CastTo(a, 'IRemoteAPI')
Should work. Otherwise, a 'normal' QI would also work, but obtaining the
IID for the interface is a little tricky...
Mark
More information about the Python-win32
mailing list