[pywin32-checkins] pywin32/com/win32comext/shell/src shell.cpp,1.41,1.42
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2006-01-12 15:20:39
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv689/com/win32comext/shell/src Modified Files: shell.cpp Log Message: Allow SHFileOperation to accept a string containing multiple file names, and some doc improvements Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** shell.cpp 29 Nov 2005 02:24:16 -0000 1.41 --- shell.cpp 12 Jan 2006 15:20:31 -0000 1.42 *************** *** 436,442 **** --- 436,453 ---- } + // @object PyCMINVOKECOMMANDINFO|A tuple of parameters to be converted to a CMINVOKECOMMANDINFO struct + // @tupleitem 0|int|Mask|Combination of shellcon.CMIC_MASK_* constants, can be 0 + // @tupleitem 1|<o PyHANDLE>|hwnd|Window that owns the shortcut menu + // @tupleitem 2|int or str|Vert|Action to be carried out, specified as a string command or integer menu item id + // @tupleitem 3|str|Parameters|Extra parameters to be passed to the command line for the action, can be None + // @tupleitem 4|str|Directory|Working directory, can be None + // @tupleitem 5|int|Show|Combination of win32con.SW_* constants for any windows that may be created + // @tupleitem 6|int|HotKey|Hot key for any application that may be started + // @tupleitem 7|<o PyHANDLE>|Icon|Handle to icon to use for application, can be None BOOL PyObject_AsCMINVOKECOMMANDINFO(PyObject *ob, CMINVOKECOMMANDINFO *pci) { PyObject *obVerb; + ZeroMemory(pci, sizeof(CMINVOKECOMMANDINFO)); + pci->cbSize=sizeof(CMINVOKECOMMANDINFO); if (!PyArg_ParseTuple(ob, "iiOzziii:CMINVOKECOMMANDINFO tuple", &pci->fMask, &pci->hwnd, &obVerb, &pci->lpParameters, &pci->lpDirectory, *************** *** 748,775 **** return TRUE; } ! if (PyString_Check(ob) || PyUnicode_Check(ob)) { ! // single string specified. ! DWORD len; ! TCHAR *sz; ! if (!PyWinObject_AsTCHAR(ob, &sz, FALSE, &len)) ! return FALSE; ! *ret = (TCHAR *)malloc( sizeof(TCHAR) * (len+2) ); ! if (!*ret) ! PyErr_NoMemory(); ! else { ! _tcscpy(*ret, sz); ! (*ret)[len+1] = '\0'; // second term. ! } PyWinObject_FreeTCHAR(sz); ! return TRUE; ! } ! ! if (!PySequence_Check(ob)) { ! PyErr_Format(PyExc_TypeError, ! "Must be a string or sequence of strings (got '%s')", ob->ob_type->tp_name); return FALSE; } ! PyErr_Format(PyExc_RuntimeError, "Sequences of names not yet supported"); ! return FALSE; } --- 759,776 ---- return TRUE; } ! DWORD len; ! TCHAR *sz; ! if (!PyWinObject_AsTCHAR(ob, &sz, FALSE, &len)) ! return FALSE; ! *ret = (TCHAR *)malloc( sizeof(TCHAR) * (len+2) ); ! if (!*ret){ PyWinObject_FreeTCHAR(sz); ! PyErr_NoMemory(); return FALSE; } ! memcpy(*ret, sz, sizeof(TCHAR) * (len+1)); ! (*ret)[len+1] = '\0'; // second term. ! PyWinObject_FreeTCHAR(sz); ! return TRUE; } *************** *** 784,788 **** } ! // @object SHFILEOPSTRUCT|A tuple representing a Win32 shell SHFILEOPSTRUCT structure. BOOL PyObject_AsSHFILEOPSTRUCT(PyObject *ob, SHFILEOPSTRUCT *p) { --- 785,792 ---- } ! // @object SHFILEOPSTRUCT|A tuple representing a Win32 shell SHFILEOPSTRUCT structure, used with <om shell.SHFileOperation> ! // @comm From and To can contain multiple file names concatenated with a single null between them, eg ! // "c:\\file1.txt\0c:\\file2.txt". A double null terminator will be appended automatically. ! // If To specifies multiple file names, flags must contain FOF_MULTIDESTFILES BOOL PyObject_AsSHFILEOPSTRUCT(PyObject *ob, SHFILEOPSTRUCT *p) { *************** *** 790,804 **** memset(p, 0, sizeof(*p)); if (!PyArg_ParseTuple(ob, "iiOO|iOO", ! &p->hwnd, // @tupleitem 0|int|hwnd| ! &p->wFunc, // @tupleitem 1|int|wFunc| ! &obFrom, // @tupleitem 2|string/list of stringsfrom|obFrom| ! &obTo, // @tupleitem 3|string/list of strings|to| ! &p->fFlags, // @tupleitem 4|int|flags|Default=0 ! &obNameMappings, // @tupleitem 5|None|nameMappings|Default=None ! &obProgressTitle)) // @tupleitem 6|string|progressTitle|Default=None return FALSE; if (obNameMappings != Py_None) { ! PyErr_SetString(PyExc_TypeError, "The nameMappings value must be None"); return FALSE; } --- 794,808 ---- memset(p, 0, sizeof(*p)); if (!PyArg_ParseTuple(ob, "iiOO|iOO", ! &p->hwnd, // @tupleitem 0|int|hwnd|Handle of window in which to display status messages ! &p->wFunc, // @tupleitem 1|int|wFunc|One of the shellcon.FO_* values ! &obFrom, // @tupleitem 2|str/unicode|From|String containing source file name(s) separated by nulls ! &obTo, // @tupleitem 3|str/unicode|To|String containing destination file name(s) separated by nulls, can be None ! &p->fFlags, // @tupleitem 4|int|flags|Combination of shellcon.FOF_* flags. Default=0 ! &obNameMappings, // @tupleitem 5|None|NameMappings|Maps input file names to their new names, must be None. Default=None ! &obProgressTitle)) // @tupleitem 6|string|ProgressTitle|Title for progress dialog (flags must contain FOF_SIMPLEPROGRESS). Default=None return FALSE; if (obNameMappings != Py_None) { ! PyErr_SetString(PyExc_TypeError, "The NameMappings value must be None"); return FALSE; } *************** *** 820,824 **** // // WIN32_FIND_DATA implementation. ! // NOTE: Cloned from win32api.cpp PyObject *PyObject_FromWIN32_FIND_DATA(WIN32_FIND_DATA &findData) { --- 824,829 ---- // // WIN32_FIND_DATA implementation. ! // NOTE: Cloned from win32api.cpp - Also exists in win32file ! ! // @object WIN32_FIND_DATA|A tuple representing a Win32 WIN32_FIND_DATA structure. PyObject *PyObject_FromWIN32_FIND_DATA(WIN32_FIND_DATA &findData) { |