From: <mha...@us...> - 2003-10-07 02:32:15
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1:/tmp/cvs-serv2042 Modified Files: PyIExtractIcon.cpp PyIExtractIcon.h Log Message: Make Unicode aware, and allow the IExtractIcon interfaces to return a different HRESULT rather than the values. Index: PyIExtractIcon.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIExtractIcon.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIExtractIcon.cpp 6 Oct 2003 12:47:57 -0000 1.1 --- PyIExtractIcon.cpp 7 Oct 2003 02:32:11 -0000 1.2 *************** *** 1,8 **** // This file implements the IExtractIcon Interface and Gateway for Python. // Generated by makegw.py - #include "shell_pch.h" #include "PyIExtractIcon.h" - // @doc - This file contains autoduck documentation // --------------------------------------------------- --- 1,6 ---- *************** *** 70,74 **** if ( !PyArg_ParseTuple(args, "i|i:GetIconLocation", &uFlags, &cchMax)) return NULL; ! TCHAR *buf = (char *)malloc(cchMax * sizeof(TCHAR)); if (!buf) return PyErr_NoMemory(); --- 68,72 ---- if ( !PyArg_ParseTuple(args, "i|i:GetIconLocation", &uFlags, &cchMax)) return NULL; ! TCHAR *buf = (TCHAR *)malloc(cchMax * sizeof(TCHAR)); if (!buf) return PyErr_NoMemory(); *************** *** 105,109 **** // Gateway Implementation STDMETHODIMP PyGExtractIcon::Extract( ! /* [unique][in] */ LPCSTR pszFile, /* [unique][in] */ UINT nIconIndex, /* [out] */ HICON * phiconLarge, --- 103,107 ---- // Gateway Implementation STDMETHODIMP PyGExtractIcon::Extract( ! /* [unique][in] */ LPCTSTR pszFile, /* [unique][in] */ UINT nIconIndex, /* [out] */ HICON * phiconLarge, *************** *** 113,128 **** PY_GATEWAY_METHOD; PyObject *obpszFile; ! obpszFile = PyWinObject_FromTCHAR((LPSTR)pszFile); PyObject *result; HRESULT hr=InvokeViaPolicy("Extract", &result, "Oii", obpszFile, nIconIndex, nIconSize); Py_XDECREF(obpszFile); if (FAILED(hr)) return hr; ! PyArg_ParseTuple(result, "ii", phiconLarge, phiconSmall); ! return PyCom_HandlePythonFailureToCOM(); } STDMETHODIMP PyGExtractIcon::GetIconLocation( /* [unique][in] */ UINT uFlags, ! /* [unique][out] */ LPSTR szIconFile, /* [unique][in] */ UINT cchMax, /* [unique][out] */ LPINT piIndex, --- 111,133 ---- PY_GATEWAY_METHOD; PyObject *obpszFile; ! obpszFile = PyWinObject_FromTCHAR((LPTSTR)pszFile); PyObject *result; HRESULT hr=InvokeViaPolicy("Extract", &result, "Oii", obpszFile, nIconIndex, nIconSize); Py_XDECREF(obpszFile); if (FAILED(hr)) return hr; ! if (PyInt_Check(result) || PyLong_Check(result)) ! hr = PyInt_AsLong(result); ! else { ! PyArg_ParseTuple(result, "ii", phiconLarge, phiconSmall); ! hr = PyCom_HandlePythonFailureToCOM(); ! } ! Py_DECREF(result); ! printf("hresult is %x\n", hr); ! return hr; } STDMETHODIMP PyGExtractIcon::GetIconLocation( /* [unique][in] */ UINT uFlags, ! /* [unique][out] */ LPTSTR szIconFile, /* [unique][in] */ UINT cchMax, /* [unique][out] */ LPINT piIndex, *************** *** 130,133 **** --- 135,142 ---- { PY_GATEWAY_METHOD; + if (cchMax && szIconFile) + szIconFile[0] = 0; + *piIndex = 0; + *pflags = 0; PyObject *result; HRESULT hr=InvokeViaPolicy("GetIconLocation", &result, "i", uFlags); *************** *** 135,145 **** PyObject *obFileName; // Process the Python results, and convert back to the real params ! if (result==Py_None) ! hr = S_FALSE; else { if (PyArg_ParseTuple(result, "Oii", &obFileName, piIndex, pflags)) { TCHAR *filename; if (PyWinObject_AsTCHAR(obFileName, &filename)) { ! _tcsncpy(filename, szIconFile, cchMax); PyWinObject_FreeTCHAR(filename); } --- 144,159 ---- PyObject *obFileName; // Process the Python results, and convert back to the real params ! if (PyInt_Check(result) || PyLong_Check(result)) ! hr = PyInt_AsLong(result); else { if (PyArg_ParseTuple(result, "Oii", &obFileName, piIndex, pflags)) { TCHAR *filename; if (PyWinObject_AsTCHAR(obFileName, &filename)) { ! #ifdef UNICODE ! // WTF - _tcsncpy resolving to strncpy?! ! wcsncpy(szIconFile, filename, cchMax); ! #else ! _tcsncpy(szIconFile, filename, cchMax); ! #endif PyWinObject_FreeTCHAR(filename); } Index: PyIExtractIcon.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIExtractIcon.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIExtractIcon.h 6 Oct 2003 12:47:57 -0000 1.1 --- PyIExtractIcon.h 7 Oct 2003 02:32:11 -0000 1.2 *************** *** 34,38 **** // IExtractIcon STDMETHOD(Extract)( ! LPCSTR pszFile, UINT nIconIndex, HICON * phiconLarge, --- 34,38 ---- // IExtractIcon STDMETHOD(Extract)( ! LPCTSTR pszFile, UINT nIconIndex, HICON * phiconLarge, *************** *** 42,46 **** STDMETHOD(GetIconLocation)( UINT uFlags, ! LPSTR szIconFile, UINT cchMax, LPINT piIndex, --- 42,46 ---- STDMETHOD(GetIconLocation)( UINT uFlags, ! LPTSTR szIconFile, UINT cchMax, LPINT piIndex, |