[python-win32] hoto cast pyobject to ccompnt

Matteo Boscolo matteo.boscolo at boscolini.eu
Sun Nov 29 01:22:59 EST 2015


Il 28/11/2015 09:08, Matteo Boscolo ha scritto:
> pUnk = (IUnknown*)pyApplication;
>>>
>>>>>> Tim Roberts, timr at probo.com
>>> Providenza & Boekelheide, Inc.
>>>
>>> _______________________________________________
>>> python-win32 mailing list
>>> python-win32 at 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 at python.org
>> https://mail.python.org/mailman/listinfo/python-win32
>>
> Unfortunately when i execute the code i get an acces violation .. :(((
>
I solve it by using the pythoncom.h in this way ..
.
..
...
#include "PythonCOM.h"
.....
...
..
static PyObject *
connect(PyObject * self, PyObject * args)
{
         PyObject * pyApplication;
         CComPtr<IUnknown> pUnk;
         IUnknown *ret;
         //try to get active object
         if (!PyArg_ParseTuple(args, "O", &pyApplication))
             return NULL;

         pUnk = ((PyIUnknown *)pyApplication)->m_obj;
         HRESULT hRes = pUnk->QueryInterface(&pApp);

     Py_INCREF(Py_None);
     return Py_None;
}

regards,
Matteo



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



More information about the python-win32 mailing list