On Nov 26, 2015, at 11:34 PM, Matteo Boscolo <[email protected]>
wrote:
>
> in my cpp code I have my function that recive a com objetc from python
> into args
> from here I'm not able to cast such an object into a ccompnt
>
> static PyObject *
> connect(PyObject * self, PyObject * args)
> {
> PyObject * pyApplication;
> CComPtr<IUnknown> pUnk;
> //try to get active object
> if (!PyArg_ParseTuple(args, "O", &pyApplication))
> return NULL;
> pUnk=(CComPtr<IUnknown> )pyApplication; //<<---- not able to cast
You are just getting a compile-time error, right? That’s because the smart
pointer wrapper (CComPtr)will only accept a pointer that actually derives from
the type it is wrapping. In this case, that’s not so. You will probably have
to force the pointer to be an IUnknown* before you can wrap it in a smart
pointer.
pUnk = (IUnknown*)pyApplication;
—
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32