[pywin32-checkins] pywin32/com/win32comext/shell/src shell.cpp, 1.46, 1.47
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2006-08-02 23:05:53
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17757 Modified Files: shell.cpp Log Message: Add DragQueryFileW and SHGetPathFromIDListW, and other changes that would allow things to build with UNICODE defined (but we still don't do that) Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** shell.cpp 12 Jul 2006 12:15:29 -0000 1.46 --- shell.cpp 2 Aug 2006 23:05:43 -0000 1.47 *************** *** 478,482 **** pci->lpVerb = PyString_AsString(obVerb); } else if (PyInt_Check(obVerb)) { ! pci->lpVerb = MAKEINTRESOURCE(PyInt_AsLong(obVerb)); } else { PyErr_Format(PyExc_TypeError, "verb must be an int or string"); --- 478,482 ---- pci->lpVerb = PyString_AsString(obVerb); } else if (PyInt_Check(obVerb)) { ! pci->lpVerb = MAKEINTRESOURCEA(PyInt_AsLong(obVerb)); } else { PyErr_Format(PyExc_TypeError, "verb must be an int or string"); *************** *** 836,840 **** goto error; ! if (!PyWinObject_AsTCHAR(obProgressTitle, (LPSTR *)&p->lpszProgressTitle, TRUE)) return FALSE; return TRUE; --- 836,840 ---- goto error; ! if (!PyWinObject_AsTCHAR(obProgressTitle, (LPTSTR *)&p->lpszProgressTitle, TRUE)) return FALSE; return TRUE; *************** *** 972,979 **** } ! // @pymethod string/<o PyUnicode>|shell|SHGetPathFromIDList|Converts an IDLIST to a path. static PyObject *PySHGetPathFromIDList(PyObject *self, PyObject *args) { ! TCHAR buffer[MAX_PATH]; PyObject *rc; LPITEMIDLIST pidl; --- 972,979 ---- } ! // @pymethod string|shell|SHGetPathFromIDList|Converts an IDLIST to a path. static PyObject *PySHGetPathFromIDList(PyObject *self, PyObject *args) { ! CHAR buffer[MAX_PATH]; PyObject *rc; LPITEMIDLIST pidl; *************** *** 987,991 **** PY_INTERFACE_PRECALL; ! BOOL ok = SHGetPathFromIDList(pidl, buffer); PY_INTERFACE_POSTCALL; if (!ok) { --- 987,991 ---- PY_INTERFACE_PRECALL; ! BOOL ok = SHGetPathFromIDListA(pidl, buffer); PY_INTERFACE_POSTCALL; if (!ok) { *************** *** 993,1002 **** rc = NULL; } else ! rc = PyWinObject_FromTCHAR(buffer); PyObject_FreePIDL(pidl); return rc; } ! // @pymethod string/<o PyUnicode>|shell|SHGetSpecialFolderPath|Retrieves the path of a special folder. static PyObject *PySHGetSpecialFolderPath(PyObject *self, PyObject *args) { --- 993,1028 ---- rc = NULL; } else ! rc = PyString_FromString(buffer); PyObject_FreePIDL(pidl); return rc; } ! // @pymethod <o PyUnicode>|shell|SHGetPathFromIDListW|Converts an IDLIST to a path. ! static PyObject *PySHGetPathFromIDListW(PyObject *self, PyObject *args) ! { ! WCHAR buffer[MAX_PATH]; ! PyObject *rc; ! LPITEMIDLIST pidl; ! PyObject *obPidl; ! ! if (!PyArg_ParseTuple(args, "O:SHGetPathFromIDListW", &obPidl)) ! // @pyparm <o PyIDL>|idl||The ITEMIDLIST ! return NULL; ! if (!PyObject_AsPIDL(obPidl, &pidl)) ! return NULL; ! ! PY_INTERFACE_PRECALL; ! BOOL ok = SHGetPathFromIDListW(pidl, buffer); ! PY_INTERFACE_POSTCALL; ! if (!ok) { ! OleSetOleError(E_FAIL); ! rc = NULL; ! } else ! rc = PyWinObject_FromWCHAR(buffer); ! PyObject_FreePIDL(pidl); ! return rc; ! } ! ! // @pymethod <o PyUnicode>|shell|SHGetSpecialFolderPath|Retrieves the path of a special folder. static PyObject *PySHGetSpecialFolderPath(PyObject *self, PyObject *args) { *************** *** 1443,1447 **** PFNSHChangeNotifyRegister pfnSHChangeNotifyRegister = NULL; // This isn't always exported by name - but by ordinal 2!! ! if (hmod) pfnSHChangeNotifyRegister=(PFNSHChangeNotifyRegister)GetProcAddress(hmod, MAKEINTRESOURCE(2)); if (pfnSHChangeNotifyRegister==NULL) return OleSetOleError(E_NOTIMPL); --- 1469,1473 ---- PFNSHChangeNotifyRegister pfnSHChangeNotifyRegister = NULL; // This isn't always exported by name - but by ordinal 2!! ! if (hmod) pfnSHChangeNotifyRegister=(PFNSHChangeNotifyRegister)GetProcAddress(hmod, MAKEINTRESOURCEA(2)); if (pfnSHChangeNotifyRegister==NULL) return OleSetOleError(E_NOTIMPL); *************** *** 1483,1487 **** PFNSHChangeNotifyDeregister pfnSHChangeNotifyDeregister = NULL; // This isn't always exported by name - but by ordinal 4!! ! if (hmod) pfnSHChangeNotifyDeregister=(PFNSHChangeNotifyDeregister)GetProcAddress(hmod, MAKEINTRESOURCE(4)); if (pfnSHChangeNotifyDeregister==NULL) return OleSetOleError(E_NOTIMPL); --- 1509,1513 ---- PFNSHChangeNotifyDeregister pfnSHChangeNotifyDeregister = NULL; // This isn't always exported by name - but by ordinal 4!! ! if (hmod) pfnSHChangeNotifyDeregister=(PFNSHChangeNotifyDeregister)GetProcAddress(hmod, MAKEINTRESOURCEA(4)); if (pfnSHChangeNotifyDeregister==NULL) return OleSetOleError(E_NOTIMPL); *************** *** 1501,1509 **** } ! // @pymethod string/int|shell|DragQueryFile|Notifies the shell that an ! // image in the system image list has changed. ! // @rdesc If the value for index is -1, the result is the number of ! // filenames available, otherwise the result is a string with the ! // requested filename. static PyObject *PyDragQueryFile(PyObject *self, PyObject *args) { --- 1527,1531 ---- } ! // @pymethod int|string|shell|DragQueryFile| static PyObject *PyDragQueryFile(PyObject *self, PyObject *args) { *************** *** 1524,1528 **** return PyErr_NoMemory(); nchars = ::DragQueryFile(hglobal, index, sz, nchars); ! PyObject *ret = PyWinObject_FromTCHAR(sz, nchars); free(sz); return ret; --- 1546,1574 ---- return PyErr_NoMemory(); nchars = ::DragQueryFile(hglobal, index, sz, nchars); ! PyObject *ret = PyString_FromStringAndSize(sz, nchars); ! free(sz); ! return ret; ! } ! ! // @pymethod int|<o PyUnicode>|shell|DragQueryFileW| ! static PyObject *PyDragQueryFileW(PyObject *self, PyObject *args) ! { ! int iglobal; ! UINT index; ! if(!PyArg_ParseTuple(args, "ii:DragQueryFileW", ! &iglobal, // @pyparm int|hglobal||The HGLOBAL object - generally obtained via the 'data_handle' property of a <o PySTGMEDIUM> object. ! &index)) // @pyparm int|index||The index to retrieve. If -1, the result if an integer representing the valid index values. ! return NULL; ! HDROP hglobal = (HDROP)iglobal; ! if (index==0xFFFFFFFF) { ! return PyInt_FromLong(DragQueryFileW(hglobal, index, NULL, 0)); ! } ! // get the buffer size ! UINT nchars = DragQueryFileW(hglobal, index, NULL, 0)+2; ! WCHAR *sz = (WCHAR *)malloc(nchars * sizeof(WCHAR)); ! if (sz==NULL) ! return PyErr_NoMemory(); ! nchars = ::DragQueryFileW(hglobal, index, sz, nchars); ! PyObject *ret = PyWinObject_FromWCHAR(sz, nchars); free(sz); return ret; *************** *** 2164,2169 **** --- 2210,2217 ---- { "AssocCreate", PyAssocCreate, 1 }, // @pymeth AssocCreate|Creates a <o PyIQueryAssociations> object { "DragQueryFile", PyDragQueryFile, 1 }, // @pymeth DragQueryFile|Retrieves the file names of dropped files that have resulted from a successful drag-and-drop operation. + { "DragQueryFileW", PyDragQueryFileW, 1 }, // @pymeth DragQueryFileW|Retrieves the file names of dropped files that have resulted from a successful drag-and-drop operation. { "DragQueryPoint", PyDragQueryPoint, 1}, // @pymeth DragQueryPoint|Retrieves the position of the mouse pointer at the time a file was dropped during a drag-and-drop operation. { "SHGetPathFromIDList", PySHGetPathFromIDList, 1 }, // @pymeth SHGetPathFromIDList|Converts an <o PyIDL> to a path. + { "SHGetPathFromIDListW", PySHGetPathFromIDListW, 1 }, // @pymeth SHGetPathFromIDListW|Converts an <o PyIDL> to a unicode path. { "SHBrowseForFolder", PySHBrowseForFolder, 1 }, // @pymeth SHBrowseForFolder|Displays a dialog box that enables the user to select a shell folder. { "SHGetFileInfo", PySHGetFileInfo, 1}, // @pymeth SHGetFileInfo|Retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root. |