List Info

Thread: Implementing custom com interface, passing it to another com object for callbacks




Implementing custom com interface, passing it to another com object for callbacks
user name
2006-12-06 22:06:29
Thanks, these references are really helpful, and I think I
understand
a lot more of the path using comtypes.  Continuing with my
pseudo code
example-- this is what I think I should do:

-run GetModule() on the library, which should create the
interface foo

-Create a class implementing foo

-Create object implementing interface foo

-Pass the object to the other com function that will fire
callbacks to it

comtypes.client.GetModule('CLSID that contains foo')
class myComObjClass(COMObject):
      _com_interfaces_ = [foo]

      def foo_OnFunc1(self, this, variable1):
              do some stuff on callback
      def foo_OnFunc2(self, this, variable2):
              do some other stuff

o=myComObjClass()
otherDispatchedComObject.FunctionThatNeedsInterface(o,
otherInputs)

What I'm not sure about is the step that creates the object.
 Before,
when I tried using win32com, I thought I had to wrap a
server to pass
it-- this didn't work, so I could have been off the mark
here.  Does
this look right?  Is it really this easy?
_______________________________________________
Python-win32 mailing list
Python-win32python.org

http://mail.python.org/mailman/listinfo/python-win32
Implementing custom com interface, passing it to another com object for callbacks
user name
2006-12-07 14:09:29
johnny loops schrieb:
> Thanks, these references are really helpful, and I
think I understand
> a lot more of the path using comtypes.  Continuing with
my pseudo code
> example-- this is what I think I should do:
> 
> -run GetModule() on the library, which should create
the interface foo

Yes.

> -Create a class implementing foo

Yes.

> -Create object implementing interface foo

Yes.

> -Pass the object to the other com function that will
fire callbacks to it
> 
> comtypes.client.GetModule('CLSID that contains foo')
> class myComObjClass(COMObject):
>       _com_interfaces_ = [foo]
> 
>       def foo_OnFunc1(self, this, variable1):
>               do some stuff on callback
>       def foo_OnFunc2(self, this, variable2):
>               do some other stuff
> 
> o=myComObjClass()
> otherDispatchedComObject.FunctionThatNeedsInterface(o,
otherInputs)
> 
> What I'm not sure about is the step that creates the
object.  Before,
> when I tried using win32com, I thought I had to wrap a
server to pass
> it-- this didn't work, so I could have been off the
mark here.  Does
> this look right?  Is it really this easy?

Yes, it should work this way.  The COMObject base class
takes care of the rest.

Thomas

_______________________________________________
Python-win32 mailing list
Python-win32python.org

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

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