Convert PyIDispatch object to struct IDispatch*

H

Huayang Xia

I am trying to use ctypes to call dll functions. One of the functions
requires argument "struct IDispatch* ". I do have a PyIDispatch object
in python. How can I convert this "PyIDispatch object" to "struct
IDispatch* "?

Thanks in advance.
 
H

Huayang Xia

I think a PyIDispatch object is an IDispatch* itself.
But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32

Thanks for the info.

To call a dll function, it needs a C style IDispatch*. PyIDispatch is
a python wrapped one. I found a reference from:

http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py

which shows how to convert C style to python style. Unfortunately i
need the reversed version.

I will post the question to python-win32.
 
T

Tim Golden

Huayang said:
Thanks for the info.

To call a dll function, it needs a C style IDispatch*. PyIDispatch is
a python wrapped one. I found a reference from:

http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py

which shows how to convert C style to python style. Unfortunately i
need the reversed version.

I will post the question to python-win32.

I've had a quick look at the PyIDispatch source and I can't see any obvious
way in which the underlying IDispatch is exposed. May have missed something,
but it's possible that there's not way out.

TJG
 
H

Huayang Xia

I've had a quick look at the PyIDispatch source and I can't see any obvious
way in which the underlying IDispatch is exposed. May have missed something,
but it's possible that there's not way out.

TJG

Thanks for the info.
I read somewhere that the PyIDispatch is converted to VT_DISPATCH
automatically when passed to a C style function call. So from
VT_DISPATCH, it should be possible to get the IDispatch. That's only a
vague idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top