Il 28/11/2015 08:30, Tim Roberts ha scritto:
On Nov 26, 2015, at 11:34 PM, Matteo Boscolo <matteo.bosc...@boscolini.eu> 
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, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

sorry i did a mistake your cast seems to be ok for compyling ..



---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
http://www.avast.com

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to