On 30/07/2021 11:24 pm, William Belanger wrote:
Hi,
However, products are free to define events in whatever makes sense
for them - eg, the object could take a plain IDispatch and try and
dynamically query and deliver events to the methods here. If that's
what the app in question does, then yeah, you don't need
DispatchWithEvents and can do something simpler.
In short, Antidote binary is launched, then its IApiOle interface takes
the Dispatch object of the custom server I made and uses it to
communicate back and forth.
self.server = win32com.client.Dispatch("Correcteur.Antidote")
self.antidote = win32com.client.Dispatch("Antidote.ApiOle")
self.antidote.LanceOutilDispatch2(self.server, "C", "",
str(version)) # Server, tool, lang, API version
Using the Dispatch() method, the interface I made is working as
expected, which means that the methods exposed in AdapteurAntidote are
then being queried (updated example below). I did not try delivering
back the resuts but I assume it should work.
What I could not achieve is to get the server adapter class
(AdapteurAntidote) to work with objects which are created at runtime,
namely instances of other classes. I cannot set another runtime object
as an attribute of the adapter class, nor pass it on instantiation.
Thus, the adapter is quite useless in this case. Is it even possible
using pywin32? If so, how?
You can get and set properties which are COM objects in the same way you
can get and set any other properties.
Looking back at Antiote's C++ example, there is an idl file available
from them.
A .idl file isn't much good to pywin32 - it wants a compiled version
(aka a typelib.) I'd be quite surprised if their DLL had a .idl file and
not a compiled version of it.
Is it necessary though? I would rather do everything
dynamically, such as setting the GUID, just like I did for the DBus
interface.
In general, early-binding via a typelib should not be necessary -
however, pywin32 does far less guessing about things when a typelib
exists. It will be clearer what properties exist, what type they are and
how to call them. It may well be that it is the difference between
things working and not working. - so in this case it may well be
necessary in practice.
Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32