[pywin32-checkins] pywin32/com/win32com/src PythonCOM.cpp,1.28,1.29
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2004-04-07 05:30:35
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4863 Modified Files: PythonCOM.cpp Log Message: * OleSetClipboard should accept None (to clear the clipboard) * Add OleInitialize, as the clipboard functions insist on it. * Fix [ 858458 ] CoInitializeSecurity checks obAuthSvc is NULL not Py_None Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PythonCOM.cpp 19 Mar 2004 04:30:20 -0000 1.28 --- PythonCOM.cpp 7 Apr 2004 05:17:37 -0000 1.29 *************** *** 284,288 **** return NULL; ! if (obAuthSvc==NULL) cAuthSvc = (DWORD)-1; else if (PySequence_Check(obAuthSvc)) { --- 284,288 ---- return NULL; ! if (obAuthSvc==Py_None) cAuthSvc = (DWORD)-1; else if (PySequence_Check(obAuthSvc)) { *************** *** 1307,1311 **** return NULL; IDataObject *pd; ! if (!PyCom_InterfaceFromPyObject(obd, IID_IDataObject, (void**)&pd, FALSE)) return NULL; HRESULT hr; --- 1307,1311 ---- return NULL; IDataObject *pd; ! if (!PyCom_InterfaceFromPyObject(obd, IID_IDataObject, (void**)&pd, TRUE)) return NULL; HRESULT hr; *************** *** 1313,1317 **** hr = ::OleSetClipboard(pd); Py_END_ALLOW_THREADS ! pd->Release(); if (FAILED(hr)) { PyCom_BuildPyException(hr); --- 1313,1318 ---- hr = ::OleSetClipboard(pd); Py_END_ALLOW_THREADS ! if (pd) ! pd->Release(); if (FAILED(hr)) { PyCom_BuildPyException(hr); *************** *** 1437,1440 **** --- 1438,1460 ---- } + // @pymethod |pythoncom|OleInitialize|Calls OleInitialized - this should rarely + // be needed, although some clipboard operations insist this is called rather + // than <om pythoncom.CoInitialize> + static PyObject *pythoncom_OleInitialize(PyObject *, PyObject *args) + { + if (!PyArg_ParseTuple(args, ":OleInitialize")) + return NULL; + HRESULT hr; + Py_BEGIN_ALLOW_THREADS + hr = ::OleInitialize(NULL); + Py_END_ALLOW_THREADS + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + return NULL; + } + Py_INCREF(Py_None); + return Py_None; + } + /* List of module functions */ *************** *** 1496,1499 **** --- 1516,1520 ---- { "new", pythoncom_new, 1 }, { "New", pythoncom_new, 1 }, // @pymeth New|Create a new instance of an OLE automation server. + { "OleInitialize", pythoncom_OleInitialize, 1}, // @pymeth OleInitialize| { "OleGetClipboard", pythoncom_OleGetClipboard, 1}, // @pymeth OleGetClipboard|Retrieves a data object that you can use to access the contents of the clipboard. { "OleFlushClipboard", pythoncom_OleFlushClipboard, 1}, // @pymeth OleFlushClipboard|Carries out the clipboard shutdown sequence. It also releases the IDataObject pointer that was placed on the clipboard by the <om pythoncom.OleSetClipboard> function. |