COM interfaces and inheritance
Rob Sykes
Robert_NJ_Sykes at msn.co.uk
Tue Nov 19 12:33:17 EST 2002
Alan Kennedy <alanmk at hotmail.com> wrote in
news:3DDA31DD.35E676C0 at hotmail.com:
<snip>
> The first step is to get a handle on the module for your COM
> library, like so
>
> from win32com.client.gencache import GetModuleForProgID
> myModule = GetModuleForProgID('your.com.library.name.here')
>
This was the bit I was missing/didn't know. I'd tried doing a
regular import of the gen_py'd module, also running it in an
interpreter.
> Each possible interface in that module will have a class to
> represent it. Each of the "constructors" for those classes will
> recognise if you have passed it an instance of an object that
> implements a related interface. If you have, then it will
> return to you an instance that implements the interface you
> need.
>
> So some code might look like this
>
> objA = createObjA() # Returned object implements interface A
> objB = myModule.IInterface2(objA)
> # Bingo!
>
> At least, that works for me :-)
And it works for me :-)
Ta muchly
--
Rob Sykes
Born again Bairn | 'The despair I can live with.
rob at john-richard dot co dot uk | It's the hope I can't stand'
(header email for spambots) | (Anon.)
More information about the Python-list
mailing list