pywin32-checkins Mailing List for Python for Windows Extensions (Page 4)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <pyw...@li...> - 2012-10-26 23:58:18
|
changeset b7968cc5d12a in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=b7968cc5d12a summary: add more changes diffstat: CHANGES.txt | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diffs (23 lines): diff -r 808faef1e9ee -r b7968cc5d12a CHANGES.txt --- a/CHANGES.txt Mon Oct 15 18:04:46 2012 -0400 +++ b/CHANGES.txt Sat Oct 27 10:58:07 2012 +1100 @@ -38,7 +38,7 @@ interfaces IShellItem2, IEnumShellItems, IApplicationDocumentLists, IApplicationDestinations, ITaskbarList, IEnumObjects, IKnownFolder, IKnownFolderManager, IObjectArray, IObjectCollection, - ICustomDestinationList, and IShellLibrary + ICustomDestinationList, and IShellLibrary; enhance SHAddToRecentDocs. * win32com.propsys - Many Property System interfaces and functions added @@ -48,7 +48,9 @@ Fix iteration of objects that don't declare an enumerator in their typelib Validate syntax of constants written to makepy generated files -* win32file - Add GetFileInformationByHandleEx +* win32file - Add GetFileInformationByHandleEx, ReOpenFile and OpenFileById, + SetFileInformationByHandle. SetFileTime() has an extra param to allow UTC + time to be specified. * win32api - Allow UpdateResource to remove a resource |
From: <pyw...@li...> - 2012-10-15 22:07:34
|
changeset 9e5640b68046 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=9e5640b68046 summary: Fix Python version check for 2.3 changeset 808faef1e9ee in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=808faef1e9ee summary: Add an option to SetFileTime to indicate using UTC times, convert to keyword args diffstat: SWIG/swig_lib/python/pywintypes.i | 2 +- win32/src/win32file.i | 87 ++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 47 deletions(-) diffs (143 lines): diff -r 43671a7afd0e -r 808faef1e9ee SWIG/swig_lib/python/pywintypes.i --- a/SWIG/swig_lib/python/pywintypes.i Sun Oct 14 03:19:18 2012 -0400 +++ b/SWIG/swig_lib/python/pywintypes.i Mon Oct 15 18:04:46 2012 -0400 @@ -48,7 +48,7 @@ // this is what the 'k' format specifier in PyArg_ParseTuple uses, and // that is what much of pywin32 uses for DWORDS, so we use it here too // Also, Python 2.3 and below will not accept a plain int for the PyLong_* functions - #if (PY_VERSION_HEX < 0x02400000) + #if (PY_VERSION_HEX < 0x02040000) { PyObject *tmpLong = PyNumber_Long($source); if (tmpLong == NULL) diff -r 43671a7afd0e -r 808faef1e9ee win32/src/win32file.i --- a/win32/src/win32file.i Sun Oct 14 03:19:18 2012 -0400 +++ b/win32/src/win32file.i Mon Oct 15 18:04:46 2012 -0400 @@ -714,71 +714,65 @@ ; } -// @pyswig None|SetFileTime|Sets the date and time that a file was created, last accessed, or last modified. -static PyObject *PySetFileTime (PyObject *self, PyObject *args) +// @pyswig |SetFileTime|Sets the date and time that a file was created, last accessed, or last modified. +static PyObject *PySetFileTime (PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *obHandle; // @pyparm <o PyHANDLE>/int|handle||Previously opened handle (opened with GENERIC_WRITE access). - PyObject *obTimeCreated; // @pyparm <o PyTime>|CreatedTime||File created time. None for no change. - PyObject *obTimeAccessed; // @pyparm <o PyTime>|AccessTime||File access time. None for no change. - PyObject *obTimeWritten; // @pyparm <o PyTime>|WrittenTime||File written time. None for no change. + PyObject *obHandle; // @pyparm <o PyHANDLE>|File||Previously opened handle (opened with FILE_WRITE_ATTRIBUTES access). + PyObject *obCreationTime = Py_None; // @pyparm <o PyTime>|CreationTime|None|File created time. None for no change. + PyObject *obLastAccessTime = Py_None; // @pyparm <o PyTime>|LastAccessTime|None|File access time. None for no change. + PyObject *obLastWriteTime = Py_None; // @pyparm <o PyTime>|LastWriteTime|None|File written time. None for no change. + BOOL UTCTimes = FALSE; // @pyparm boolean|UTCTimes|False|If True, input times are treated as UTC and no conversion is done, + // otherwise they are treated as local times. Defaults to False for backward compatibility. + + static char *keywords[] = {"File", "CreationTime", "LastAccessTime", "LastWriteTime", "UTCTimes", NULL}; HANDLE hHandle; - FILETIME TimeCreated, *lpTimeCreated; - FILETIME TimeAccessed, *lpTimeAccessed; - FILETIME TimeWritten, *lpTimeWritten; - FILETIME LocalFileTime; - - if (!PyArg_ParseTuple(args, "OOOO:SetFileTime", - &obHandle, &obTimeCreated, &obTimeAccessed, &obTimeWritten)) + FILETIME CreationTime, *lpCreationTime = NULL; + FILETIME LastAccessTime, *lpLastAccessTime = NULL; + FILETIME LastWriteTime, *lpLastWriteTime = NULL; + FILETIME FileTime; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOOi:SetFileTime", keywords, + &obHandle, &obCreationTime, &obLastAccessTime, &obLastWriteTime, &UTCTimes)) return NULL; if (!PyWinObject_AsHANDLE(obHandle, &hHandle)) return NULL; - if (obTimeCreated == Py_None) - lpTimeCreated= NULL; - else - { - if (!PyWinObject_AsFILETIME(obTimeCreated, &LocalFileTime)) + if (obCreationTime != Py_None){ + if (!PyWinObject_AsFILETIME(obCreationTime, &FileTime)) return NULL; - // This sucks! This code is the only code in pywin32 that - // blindly converted the result of AsFILETIME to a localtime. - // That doesn't make sense in a tz-aware datetime world... - if (PyWinTime_DateTimeCheck(obTimeCreated)) - TimeCreated = LocalFileTime; + // Do no conversion if given a timezone-aware object, or told input is UTC + if (UTCTimes || PyWinTime_DateTimeCheck(obCreationTime)) + CreationTime = FileTime; else - LocalFileTimeToFileTime(&LocalFileTime, &TimeCreated); - lpTimeCreated= &TimeCreated; + LocalFileTimeToFileTime(&FileTime, &CreationTime); + lpCreationTime = &CreationTime; } - if (obTimeAccessed == Py_None) - lpTimeAccessed= NULL; - else - { - if (!PyWinObject_AsFILETIME(obTimeAccessed, &LocalFileTime)) + if (obLastAccessTime != Py_None){ + if (!PyWinObject_AsFILETIME(obLastAccessTime, &FileTime)) return NULL; - if (PyWinTime_DateTimeCheck(obTimeAccessed)) - TimeAccessed = LocalFileTime; + if (UTCTimes || PyWinTime_DateTimeCheck(obLastAccessTime)) + LastAccessTime = FileTime; else - LocalFileTimeToFileTime(&LocalFileTime, &TimeAccessed); - lpTimeAccessed= &TimeAccessed; + LocalFileTimeToFileTime(&FileTime, &LastAccessTime); + lpLastAccessTime= &LastAccessTime; } - if (obTimeWritten == Py_None) - lpTimeWritten= NULL; - else - { - if (!PyWinObject_AsFILETIME(obTimeWritten, &LocalFileTime)) + if (obLastWriteTime != Py_None){ + if (!PyWinObject_AsFILETIME(obLastWriteTime, &FileTime)) return NULL; - if (PyWinTime_DateTimeCheck(obTimeWritten)) - TimeWritten = LocalFileTime; + if (UTCTimes || PyWinTime_DateTimeCheck(obLastWriteTime)) + LastWriteTime = FileTime; else - LocalFileTimeToFileTime(&LocalFileTime, &TimeWritten); - lpTimeWritten= &TimeWritten; + LocalFileTimeToFileTime(&FileTime, &LastWriteTime); + lpLastWriteTime= &LastWriteTime; } - if (!::SetFileTime(hHandle, lpTimeCreated, lpTimeAccessed, lpTimeWritten)) + if (!::SetFileTime(hHandle, lpCreationTime, lpLastAccessTime, lpLastWriteTime)) return PyWin_SetAPIError("SetFileTime"); Py_INCREF(Py_None); return Py_None; } +PyCFunction pfnPySetFileTime = (PyCFunction)PySetFileTime; %} -%native(SetFileTime) PySetFileTime; +%native(SetFileTime) pfnPySetFileTime; %{ // @pyswig tuple|GetFileInformationByHandle|Retrieves file information for a specified file. @@ -878,7 +872,7 @@ // of arbitary size, so currently this can only be created by <om win32file.AllocateReadBuffer>. #ifndef MS_WINCE %{ -// @pyswig <o PyOVERLAPPEDReadBuffer>|AllocateReadBuffer|Allocated a buffer which can be used with an overlapped Read operation using <om win32file.ReadFile> +// @pyswig <o PyOVERLAPPEDReadBuffer>|AllocateReadBuffer|Allocates a buffer which can be used with an overlapped Read operation using <om win32file.ReadFile> PyObject *MyAllocateReadBuffer(PyObject *self, PyObject *args) { int bufSize; @@ -6025,6 +6019,7 @@ ||(strcmp(pmd->ml_name, "ConnectEx")==0) ||(strcmp(pmd->ml_name, "ReOpenFile")==0) ||(strcmp(pmd->ml_name, "OpenFileById")==0) + ||(strcmp(pmd->ml_name, "SetFileTime")==0) ) pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; |
From: <pyw...@li...> - 2012-10-14 07:21:36
|
changeset 43671a7afd0e in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=43671a7afd0e summary: Add ReOpenFile and OpenFileById diffstat: win32/src/win32file.i | 102 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 100 insertions(+), 2 deletions(-) diffs (158 lines): diff -r 52a6d13dba29 -r 43671a7afd0e win32/src/win32file.i --- a/win32/src/win32file.i Sat Oct 13 18:51:03 2012 -0400 +++ b/win32/src/win32file.i Sun Oct 14 03:19:18 2012 -0400 @@ -3009,6 +3009,13 @@ typedef BOOL (WINAPI *SetFileInformationByHandlefunc)(HANDLE,FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD); static SetFileInformationByHandlefunc pfnSetFileInformationByHandle = NULL; +typedef HANDLE (WINAPI *ReOpenFilefunc)(HANDLE, DWORD, DWORD, DWORD); +static ReOpenFilefunc pfnReOpenFile = NULL; + +typedef HANDLE (WINAPI *OpenFileByIdfunc)(HANDLE, LPFILE_ID_DESCRIPTOR, DWORD, DWORD, + LPSECURITY_ATTRIBUTES, DWORD); +static OpenFileByIdfunc pfnOpenFileById = NULL; + // From sfc.dll typedef BOOL (WINAPI *SfcGetNextProtectedFilefunc)(HANDLE,PPROTECTED_FILE_DATA); static SfcGetNextProtectedFilefunc pfnSfcGetNextProtectedFile = NULL; @@ -5484,7 +5491,7 @@ // @pyparm <o PyHANDLE>|File||Handle to a file or directory. Do not pass a pipe handle. // @pyparm int|FileInformationClass||Type of data to return, one of win32file.File*Info values - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i:GetFileInformationByHandleEx", keywords, PyWinObject_AsHANDLE, &handle, &info_class)) return NULL; @@ -5698,7 +5705,7 @@ // @pyparm <o PyHANDLE>|File||Handle to a file or directory. Do not pass a pipe handle. // @pyparm int|FileInformationClass||Type of data, one of win32file.File*Info values // @pyparm object|Information||Type is dependent on the class to be changed - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&iO", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&iO:SetFileInformationByHandle", keywords, PyWinObject_AsHANDLE, &handle, &info_class, &info)) return NULL; @@ -5833,6 +5840,86 @@ PyCFunction pfnpy_SetFileInformationByHandle=(PyCFunction)py_SetFileInformationByHandle; %} +%{ +// @pyswig <o PyHANDLE>|ReOpenFile|Creates a new handle to an open file +// @comm Available on Vista and later. +// @comm Accepts keyword args. +static PyObject *py_ReOpenFile(PyObject *self, PyObject *args, PyObject *kwargs) +{ + CHECK_PFN(ReOpenFile); + static char *keywords[] = {"OriginalFile", "DesiredAccess", "ShareMode", "Flags", NULL}; + HANDLE horig, hret; + DWORD DesiredAccess, ShareMode, Flags; + // @pyparm <o PyHANDLE>|OriginalFile||An open file handle + // @pyparm int|DesiredAccess||Access mode, cannot conflict with original access mode + // @pyparm int|ShareMode||Sharing mode (FILE_SHARE_*), cannot conflict with original share mode + // @pyparm int|Flags||Combination of FILE_FLAG_* flags + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&kkk:ReOpenFile", keywords, + PyWinObject_AsHANDLE, &horig, &DesiredAccess, &ShareMode, &Flags)) + return NULL; + + Py_BEGIN_ALLOW_THREADS + hret = (*pfnReOpenFile)(horig, DesiredAccess, ShareMode, Flags); + // hret = ReOpenFile(horig, DesiredAccess, ShareMode, Flags); + Py_END_ALLOW_THREADS + if (hret == INVALID_HANDLE_VALUE) + return PyWin_SetAPIError("ReOpenFile"); + return PyWinObject_FromHANDLE(hret); +} +PyCFunction pfnpy_ReOpenFile=(PyCFunction)py_ReOpenFile; +%} + +%{ +// @pyswig <o PyHANDLE>|OpenFileById|Opens a file by File Id or Object Id +// @comm Available on Vista and later. +// @comm Accepts keyword args. +static PyObject *py_OpenFileById(PyObject *self, PyObject *args, PyObject *kwargs) +{ + CHECK_PFN(OpenFileById); + static char *keywords[] = {"File", "FileID", "DesiredAccess", "ShareMode", + "Flags", "SecurityAttributes", NULL}; + HANDLE hvol, hret; + DWORD DesiredAccess, ShareMode, Flags; + PyObject *obsa = Py_None; + PSECURITY_ATTRIBUTES sa; + PyObject *obfileid; + FILE_ID_DESCRIPTOR fileid = {sizeof(FILE_ID_DESCRIPTOR)}; + + // @pyparm <o PyHANDLE>|File||Handle to a file on the volume that contains the file to open + // @pyparm int/<o PyIID>|FileId||File Id or Object Id of the file to open + // @pyparm int|DesiredAccess||Access mode + // @pyparm int|ShareMode||Sharing mode (FILE_SHARE_*) + // @pyparm int|Flags||Combination of FILE_FLAG_* flags + // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Reserved, use only None + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Okkk|O:OpenFileById", keywords, + PyWinObject_AsHANDLE, &hvol, &obfileid, &DesiredAccess, &ShareMode, &Flags, &obsa)) + return NULL; + if (!PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &sa, TRUE)) + return NULL; + + fileid.Type = FileIdType; + if (!PyWinObject_AsLARGE_INTEGER(obfileid, &fileid.FileId)){ + PyErr_Clear(); + fileid.Type = ObjectIdType; + if (!PyWinObject_AsIID(obfileid, &fileid.ObjectId)){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, "FileId must be an integer or GUID"); + return NULL; + } + } + + Py_BEGIN_ALLOW_THREADS + hret = (*pfnOpenFileById)(hvol, &fileid, DesiredAccess, ShareMode, sa, Flags); + // hret = OpenFileById(hvol, &fileid, DesiredAccess, ShareMode, sa, Flags); + Py_END_ALLOW_THREADS + if (hret == INVALID_HANDLE_VALUE) + return PyWin_SetAPIError("OpenFileById"); + return PyWinObject_FromHANDLE(hret); +} +PyCFunction pfnpy_OpenFileById=(PyCFunction)py_OpenFileById; +%} + + %native (SetVolumeMountPoint) pfnpy_SetVolumeMountPoint; %native (DeleteVolumeMountPoint) pfnpy_DeleteVolumeMountPoint; %native (GetVolumeNameForVolumeMountPoint) pfnpy_GetVolumeNameForVolumeMountPoint; @@ -5886,6 +5973,9 @@ %native (Wow64DisableWow64FsRedirection) py_Wow64DisableWow64FsRedirection; %native (Wow64RevertWow64FsRedirection) py_Wow64RevertWow64FsRedirection; +%native (ReOpenFile) pfnpy_ReOpenFile; +%native (OpenFileById) pfnpy_OpenFileById; + %init %{ @@ -5933,6 +6023,8 @@ ||(strcmp(pmd->ml_name, "DeviceIoControl")==0) ||(strcmp(pmd->ml_name, "TransmitFile")==0) ||(strcmp(pmd->ml_name, "ConnectEx")==0) + ||(strcmp(pmd->ml_name, "ReOpenFile")==0) + ||(strcmp(pmd->ml_name, "OpenFileById")==0) ) pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; @@ -6004,6 +6096,8 @@ pfnSetFileInformationByHandle=(SetFileInformationByHandlefunc)GetProcAddress(hmodule, "SetFileInformationByHandle"); pfnWow64DisableWow64FsRedirection=(Wow64DisableWow64FsRedirectionfunc)GetProcAddress(hmodule, "Wow64DisableWow64FsRedirection"); pfnWow64RevertWow64FsRedirection=(Wow64RevertWow64FsRedirectionfunc)GetProcAddress(hmodule, "Wow64RevertWow64FsRedirection"); + pfnReOpenFile=(ReOpenFilefunc)GetProcAddress(hmodule, "ReOpenFile"); + pfnOpenFileById=(OpenFileByIdfunc)GetProcAddress(hmodule, "OpenFileById"); } hmodule=GetModuleHandle(TEXT("sfc.dll")); @@ -6135,3 +6229,7 @@ #define IoPriorityHintVeryLow IoPriorityHintVeryLow #define IoPriorityHintLow IoPriorityHintLow #define IoPriorityHintNormal IoPriorityHintNormal + +// used with OpenFileById +#define FileIdType FileIdType +#define ObjectIdType ObjectIdType |
From: <pyw...@li...> - 2012-10-13 22:58:57
|
changeset 52a6d13dba29 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=52a6d13dba29 summary: Make sure PIDL is freed in case of error; fix unaligned warning on x64 diffstat: com/win32comext/shell/src/PyIShellFolder.cpp | 7 ++++--- com/win32comext/shell/src/PyIShellFolder2.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diffs (44 lines): diff -r 987270c70afc -r 52a6d13dba29 com/win32comext/shell/src/PyIShellFolder.cpp --- a/com/win32comext/shell/src/PyIShellFolder.cpp Fri Oct 12 16:25:41 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellFolder.cpp Sat Oct 13 18:51:03 2012 -0400 @@ -366,10 +366,11 @@ PY_INTERFACE_PRECALL; hr = pISF->GetDisplayNameOf( pidl, uFlags, &out ); PY_INTERFACE_POSTCALL; - + PyObject *ret; if ( FAILED(hr) ) - return PyCom_BuildPyException(hr, pISF, IID_IShellFolder ); - PyObject *ret = PyObject_FromSTRRET(&out, pidl, TRUE); + ret = PyCom_BuildPyException(hr, pISF, IID_IShellFolder); + else + ret = PyObject_FromSTRRET(&out, pidl, TRUE); PyObject_FreePIDL(pidl); return ret; } diff -r 987270c70afc -r 52a6d13dba29 com/win32comext/shell/src/PyIShellFolder2.cpp --- a/com/win32comext/shell/src/PyIShellFolder2.cpp Fri Oct 12 16:25:41 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellFolder2.cpp Sat Oct 13 18:51:03 2012 -0400 @@ -148,7 +148,7 @@ // @pyparm int|iColumn||Zero based index of column SHELLDETAILS sd; PyObject *obpidl; - LPITEMIDLIST pidl; + ITEMIDLIST *pidl; UINT iColumn; if (!PyArg_ParseTuple(args, "Oi:GetDetailsOf", &obpidl, &iColumn)) return NULL; @@ -158,9 +158,11 @@ PY_INTERFACE_PRECALL; hr = pISF2->GetDetailsOf( pidl, iColumn, &sd ); PY_INTERFACE_POSTCALL; + PyObject *ret; if ( FAILED(hr) ) - return PyCom_BuildPyException(hr, pISF2, IID_IShellFolder2 ); - PyObject *ret = Py_BuildValue("(iiN)", sd.fmt, sd.cxChar, PyObject_FromSTRRET(&sd.str, pidl, TRUE)); + ret = PyCom_BuildPyException(hr, pISF2, IID_IShellFolder2); + else + ret = Py_BuildValue("(iiN)", sd.fmt, sd.cxChar, PyObject_FromSTRRET(&sd.str, pidl, TRUE)); PyObject_FreePIDL(pidl); return ret; } |
From: <pyw...@li...> - 2012-10-12 20:26:46
|
changeset 987270c70afc in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=987270c70afc summary: Add win32file.SetFileInformationByHandle diffstat: win32/src/win32file.i | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 162 insertions(+), 0 deletions(-) diffs (204 lines): diff -r fe79b4ae1b7e -r 987270c70afc win32/src/win32file.i --- a/win32/src/win32file.i Thu Oct 04 13:48:35 2012 -0400 +++ b/win32/src/win32file.i Fri Oct 12 16:25:41 2012 -0400 @@ -3006,6 +3006,8 @@ */ typedef BOOL (WINAPI *GetFileInformationByHandleExfunc)(HANDLE,FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD); static GetFileInformationByHandleExfunc pfnGetFileInformationByHandleEx = NULL; +typedef BOOL (WINAPI *SetFileInformationByHandlefunc)(HANDLE,FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD); +static SetFileInformationByHandlefunc pfnSetFileInformationByHandle = NULL; // From sfc.dll typedef BOOL (WINAPI *SfcGetNextProtectedFilefunc)(HANDLE,PPROTECTED_FILE_DATA); @@ -5678,6 +5680,159 @@ PyCFunction pfnpy_GetFileInformationByHandleEx=(PyCFunction)py_GetFileInformationByHandleEx; %} +%{ +// @pyswig |SetFileInformationByHandle|Changes file characteristics by file handle +// @comm Available on Vista and later. +// @comm Accepts keyword args. +static PyObject *py_SetFileInformationByHandle(PyObject *self, PyObject *args, PyObject *kwargs) +{ + CHECK_PFN(SetFileInformationByHandle); + static char *keywords[] = {"File", "FileInformationClass", "Information", NULL}; + HANDLE handle; + FILE_INFO_BY_HANDLE_CLASS info_class; + void *buf = NULL; + DWORD buflen = 0; + BOOL rc = FALSE; + PyObject *info; + + // @pyparm <o PyHANDLE>|File||Handle to a file or directory. Do not pass a pipe handle. + // @pyparm int|FileInformationClass||Type of data, one of win32file.File*Info values + // @pyparm object|Information||Type is dependent on the class to be changed + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&iO", keywords, + PyWinObject_AsHANDLE, &handle, + &info_class, &info)) + return NULL; + + // @flagh Class|Type of input + switch (info_class){ + // @flag FileBasicInfo|Dict representing a FILE_BASIC_INFO struct, containing + // {"CreationTime":<o PyTime>, "LastAccessTime":<o PyTime>, "LastWriteTime":<o PyTime>, + // "ChangeTime":<o PyTime>, "FileAttributes":int} + case FileBasicInfo:{ + TmpPyObject dummy_tuple = PyTuple_New(0); + if (dummy_tuple == NULL) + return NULL; + buflen = sizeof(FILE_BASIC_INFO); + FILE_BASIC_INFO *pbi = (FILE_BASIC_INFO *)malloc(buflen); + if (pbi == NULL) + break; + buf = pbi; + static char *keywords[] = {"CreationTime", "LastAccessTime", "LastWriteTime", + "ChangeTime", "FileAttributes", NULL}; + // The times are LARGE_INTEGER's (identical to timestamp), but can be converted as FILETIME's. + rc = PyArg_ParseTupleAndKeywords(dummy_tuple, info, "O&O&O&O&k", keywords, + PyWinObject_AsFILETIME, &pbi->CreationTime, + PyWinObject_AsFILETIME, &pbi->LastAccessTime, + PyWinObject_AsFILETIME, &pbi->LastWriteTime, + PyWinObject_AsFILETIME, &pbi->ChangeTime, + &pbi->FileAttributes); + break; + } + // @flag FileRenameInfo|Dict representing a FILE_RENAME_INFO struct, containing + // {"ReplaceIfExists":boolean, "RootDirectory":<o PyHANDLE>, "FileName":str} + // MSDN says the RootDirectory is "A handle to the root directory in which the file to be renamed is located". + // However, this is actually the destination dir, can be None to stay in same dir. + case FileRenameInfo:{ + TmpPyObject dummy_tuple = PyTuple_New(0); + if (dummy_tuple == NULL) + return NULL; + // Variable size struct, need to convert filename first to determine full length + FILE_RENAME_INFO *pri; + PyObject *obFileName; + TmpWCHAR FileName; + DWORD FileNameLength; + BOOL ReplaceIfExists; + HANDLE RootDirectory; + + static char *keywords[] = {"ReplaceIfExists", "RootDirectory", "FileName", NULL}; + rc = PyArg_ParseTupleAndKeywords(dummy_tuple, info, "iO&O", keywords, + &ReplaceIfExists, + PyWinObject_AsHANDLE, &RootDirectory, + &obFileName) + && PyWinObject_AsWCHAR(obFileName, &FileName, FALSE, &FileNameLength); + if (!rc) + return NULL; + buflen = sizeof(FILE_RENAME_INFO) + (FileNameLength * sizeof(WCHAR)); + pri = (FILE_RENAME_INFO *)malloc(buflen); + if (pri == NULL) + break; + buf = pri; + pri->ReplaceIfExists = ReplaceIfExists; + pri->RootDirectory = RootDirectory; + wcsncpy(pri->FileName, FileName, FileNameLength + 1); + pri->FileNameLength = FileNameLength * sizeof(WCHAR); + break; + } + // @flag FileDispositionInfo|Boolean indicating if file should be deleted when handle is closed + case FileDispositionInfo:{ + buflen = sizeof(FILE_DISPOSITION_INFO); + FILE_DISPOSITION_INFO *pdi = (FILE_DISPOSITION_INFO *)malloc(buflen); + if (pdi == NULL) + break; + buf = pdi; + // Thought this always succeeded, need to add error checking to other places it's used + pdi->DeleteFile = PyObject_IsTrue(info); + rc = pdi->DeleteFile != -1; + break; + } + // @flag FileAllocationInfo|Int giving the allocation size. + case FileAllocationInfo:{ + buflen = sizeof(FILE_ALLOCATION_INFO); + FILE_ALLOCATION_INFO *pai = (FILE_ALLOCATION_INFO *)malloc(buflen); + if (pai == NULL) + break; + buf = pai; + rc = PyWinObject_AsLARGE_INTEGER(info, &pai->AllocationSize); + break; + } + // @flag FileEndOfFileInfo|Int giving the EOF position, cannot be greater than allocated size. + case FileEndOfFileInfo:{ + buflen = sizeof(FILE_END_OF_FILE_INFO); + FILE_END_OF_FILE_INFO *peofi = (FILE_END_OF_FILE_INFO *)malloc(buflen); + if (peofi == NULL) + break; + buf = peofi; + rc = PyWinObject_AsLARGE_INTEGER(info, &peofi->EndOfFile); + break; + } + // @flag FileIoPriorityHintInfo|Int containing the IO priority (IoPriorityHint*) + case FileIoPriorityHintInfo:{ + buflen = sizeof(FILE_IO_PRIORITY_HINT_INFO); + FILE_IO_PRIORITY_HINT_INFO *piohi= (FILE_IO_PRIORITY_HINT_INFO *)malloc(buflen); + if (piohi == NULL) + break; + buf = piohi; + piohi->PriorityHint = (PRIORITY_HINT)PyInt_AsLong(info); + rc = piohi->PriorityHint != -1 || !PyErr_Occurred(); + break; + } + default: + PyErr_SetString(PyExc_NotImplementedError, "Unsupported file information class"); + return NULL; + } + if (buf == NULL){ + PyErr_NoMemory(); + return NULL; + } + if (!rc){ + free(buf); + return NULL; + } + + Py_BEGIN_ALLOW_THREADS + rc = (*pfnSetFileInformationByHandle)(handle, info_class, buf, buflen); + // rc = SetFileInformationByHandle(handle, info_class, buf, buflen); + Py_END_ALLOW_THREADS + free(buf); + if (rc){ + Py_INCREF(Py_None); + return Py_None; + } + return PyWin_SetAPIError("SetFileInformationByHandle"); +} +PyCFunction pfnpy_SetFileInformationByHandle=(PyCFunction)py_SetFileInformationByHandle; +%} + %native (SetVolumeMountPoint) pfnpy_SetVolumeMountPoint; %native (DeleteVolumeMountPoint) pfnpy_DeleteVolumeMountPoint; %native (GetVolumeNameForVolumeMountPoint) pfnpy_GetVolumeNameForVolumeMountPoint; @@ -5714,6 +5869,7 @@ %native (GetFileAttributesEx) pfnpy_GetFileAttributesEx; %native (GetFileAttributesExW) pfnpy_GetFileAttributesExW; %native (GetFileInformationByHandleEx) pfnpy_GetFileInformationByHandleEx; +%native (SetFileInformationByHandle) pfnpy_SetFileInformationByHandle; %native (SetFileAttributesW) pfnpy_SetFileAttributesW; %native (CreateDirectoryExW) pfnpy_CreateDirectoryExW; %native (RemoveDirectory) pfnpy_RemoveDirectory; @@ -5773,6 +5929,7 @@ ||(strcmp(pmd->ml_name, "GetLongPathName")==0) ||(strcmp(pmd->ml_name, "GetFullPathName")==0) ||(strcmp(pmd->ml_name, "GetFileInformationByHandleEx")==0) + ||(strcmp(pmd->ml_name, "SetFileInformationByHandle")==0) ||(strcmp(pmd->ml_name, "DeviceIoControl")==0) ||(strcmp(pmd->ml_name, "TransmitFile")==0) ||(strcmp(pmd->ml_name, "ConnectEx")==0) @@ -5844,6 +6001,7 @@ pfnGetFullPathNameTransactedW=(GetFullPathNameTransactedWfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedW"); pfnGetFullPathNameTransactedA=(GetFullPathNameTransactedAfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedA"); pfnGetFileInformationByHandleEx=(GetFileInformationByHandleExfunc)GetProcAddress(hmodule, "GetFileInformationByHandleEx"); + pfnSetFileInformationByHandle=(SetFileInformationByHandlefunc)GetProcAddress(hmodule, "SetFileInformationByHandle"); pfnWow64DisableWow64FsRedirection=(Wow64DisableWow64FsRedirectionfunc)GetProcAddress(hmodule, "Wow64DisableWow64FsRedirection"); pfnWow64RevertWow64FsRedirection=(Wow64RevertWow64FsRedirectionfunc)GetProcAddress(hmodule, "Wow64RevertWow64FsRedirection"); } @@ -5973,3 +6131,7 @@ #define FileIdBothDirectoryInfo FileIdBothDirectoryInfo #define FileIdBothDirectoryRestartInfo FileIdBothDirectoryRestartInfo #define FileIoPriorityHintInfo FileIoPriorityHintInfo + +#define IoPriorityHintVeryLow IoPriorityHintVeryLow +#define IoPriorityHintLow IoPriorityHintLow +#define IoPriorityHintNormal IoPriorityHintNormal |
From: <pyw...@li...> - 2012-10-04 17:50:15
|
changeset fe79b4ae1b7e in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=fe79b4ae1b7e summary: CMINVOKECOMMANDINFO.lpVerb is always plain char (bug #3574188) diffstat: com/win32comext/shell/src/shell.cpp | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 4363710e738e -r fe79b4ae1b7e com/win32comext/shell/src/shell.cpp --- a/com/win32comext/shell/src/shell.cpp Mon Oct 01 17:08:19 2012 -0400 +++ b/com/win32comext/shell/src/shell.cpp Thu Oct 04 13:48:35 2012 -0400 @@ -583,7 +583,7 @@ return FALSE; if (!PyWinObject_AsHANDLE(obhIcon, (HANDLE *)&pci->hIcon)) return FALSE; - if (!PyWinObject_AsResourceId(obVerb, (char **)&pci->lpVerb)) + if (!PyWinObject_AsResourceIdA(obVerb, (char **)&pci->lpVerb)) return FALSE; return TRUE; } |
From: <pyw...@li...> - 2012-10-01 21:09:19
|
changeset 4363710e738e in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=4363710e738e summary: Allow SHAddToRecentDocs to accept Windows 7 AppID information diffstat: com/win32comext/shell/src/shell.cpp | 194 +++++++++++++++++++++++++++++------ 1 files changed, 160 insertions(+), 34 deletions(-) diffs (271 lines): diff -r 789a2c39b4fa -r 4363710e738e com/win32comext/shell/src/shell.cpp --- a/com/win32comext/shell/src/shell.cpp Sun Sep 30 17:38:34 2012 -0400 +++ b/com/win32comext/shell/src/shell.cpp Mon Oct 01 17:08:19 2012 -0400 @@ -1422,28 +1422,161 @@ } // @pymethod |shell|SHAddToRecentDocs|Adds a document to the shell's list of recently used documents or clears all documents from the list. The user gains access to the list through the Start menu of the Windows taskbar. +// @comm On Windows 7, the entry is also added to the application's jump list. // @pyseeapi SHAddToRecentDocs // @comm The underlying API function has no return value, and therefore no way to indicate failure. static PyObject *PySHAddToRecentDocs(PyObject *self, PyObject *args) { int flags; - void *whatever; - Py_ssize_t cb; // not used, but must accept strings containing NULL bytes - if(!PyArg_ParseTuple(args, "iz#:SHAddToRecentDocs", - &flags, // @pyparm int|flags||Value from SHARD enum indicating type of data passed in second arg - &whatever, // @pyparm string/buffer|data||A file system path or PIDL (see <om shell.PIDLAsString>) identifying a shell object. - &cb)) // In Windows 7, some flags require a buffer containing one of various structs. - // Pass None to clear list of recent documents. + PyObject *ob; + if(!PyArg_ParseTuple(args, "iO:SHAddToRecentDocs", + &flags, // @pyparm int|Flags||Value from SHARD enum indicating how the item is identified. + &ob)) // @pyparm object|data||Type of input is determined by the SHARD_* flag. Use None to clear recent items list. return NULL; - PY_INTERFACE_PRECALL; - SHAddToRecentDocs(flags, whatever); - PY_INTERFACE_POSTCALL; + if (ob == Py_None){ + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, NULL); + PY_INTERFACE_POSTCALL; + Py_INCREF(Py_None); + return Py_None; + } + switch(flags){ + // @flagh Flags|Type of input + case SHARD_PATHA:{ + // @flag SHARD_PATHA|String containing a file path + char *buf; + if (!PyWinObject_AsString(ob, &buf, FALSE)) + return NULL; + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, buf); + PY_INTERFACE_POSTCALL; + PyWinObject_FreeString(buf); + break; + } + case SHARD_PATHW:{ + // @flag SHARD_PATHW|String containing a file path + WCHAR *buf; + if (!PyWinObject_AsWCHAR(ob, &buf, FALSE)) + return NULL; + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, buf); + PY_INTERFACE_POSTCALL; + PyWinObject_FreeWCHAR(buf); + break; + } + case SHARD_PIDL:{ + // @flag SHARD_PIDL|<o PyIDL>, or a buffer containing a PIDL (see <om shell.PIDLAsString>) + LPITEMIDLIST buf; + bool freepidl = FALSE; + if (PyObject_AsPIDL(ob, &buf, FALSE)) + freepidl = TRUE; + else{ + // Also accept a string containing a contiguous PIDL for backward compatibility + PyErr_Clear(); + DWORD buflen; + if (!PyWinObject_AsReadBuffer(ob, (void **)&buf, &buflen, FALSE)) + return NULL; + } + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, buf); + PY_INTERFACE_POSTCALL; + if (freepidl) + PyObject_FreePIDL(buf); + break; + } +#if WINVER >= 0x0601 + // Introduced in Windows 7 + case SHARD_APPIDINFO:{ + // @flag SHARD_APPIDINFO|Tuple of (<o PyIShellItem>, str), where str is an AppID + SHARDAPPIDINFO buf; + TmpWCHAR appid; + PyObject *obitem, *obappid; + if (!PyArg_ParseTuple(ob, "OO;SHARDAPPIDINFO must be a tuple of (<o PyIShellItem>, str)", + &obitem, &obappid)) + return NULL; + if (!PyWinObject_AsWCHAR(obappid, &appid, FALSE)) + return NULL; + buf.pszAppID = appid; + if (!PyCom_InterfaceFromPyObject(obitem, IID_IShellItem, (void **)&buf.psi, FALSE)) + return NULL; + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, &buf); + buf.psi->Release(); + PY_INTERFACE_POSTCALL; + break; + } + case SHARD_APPIDINFOIDLIST:{ + // @flag SHARD_APPIDINFOIDLIST|Tuple of (<o PyIDL>, str), where str is an AppID + SHARDAPPIDINFOIDLIST buf; + LPITEMIDLIST pidl; + TmpWCHAR appid; + PyObject *obitem, *obappid; + if (!PyArg_ParseTuple(ob, "OO;SHARDAPPIDINFOIDLIST must be tuple of (<o PyIDL>, str)", + &obitem, &obappid)) + return NULL; + if (!PyWinObject_AsWCHAR(obappid, &appid, FALSE)) + return NULL; + buf.pszAppID = appid; + if (!PyObject_AsPIDL(obitem, &pidl, FALSE)) + return NULL; + buf.pidl = pidl; + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, &buf); + PY_INTERFACE_POSTCALL; + PyObject_FreePIDL(pidl); + break; + } + case SHARD_LINK:{ + // @flag SHARD_LINK|<o PyIShellLink> + IShellLink *buf; + if (!PyCom_InterfaceFromPyObject(ob, IID_IShellLink, (void **)&buf, FALSE)) + return NULL; + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, buf); + buf->Release(); + PY_INTERFACE_POSTCALL; + break; + } + case SHARD_APPIDINFOLINK:{ + // @flag SHARD_APPIDINFOLINK|Tuple of (<o PyIShellLink>, str) where str is an AppID + SHARDAPPIDINFOLINK buf; + TmpWCHAR appid; + PyObject *obitem, *obappid; + if (!PyArg_ParseTuple(ob, "OO;SHARDAPPIDINFOLINK must be a tuple of (<o PyIShellLink>, str)", + &obitem, &obappid)) + return NULL; + if (!PyWinObject_AsWCHAR(obappid, &appid, FALSE)) + return NULL; + buf.pszAppID = appid; + if (!PyCom_InterfaceFromPyObject(obitem, IID_IShellLink, (void **)&buf.psl, FALSE)) + return NULL; + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, &buf); + buf.psl->Release(); + PY_INTERFACE_POSTCALL; + break; + } + case SHARD_SHELLITEM:{ + // @flag SHARD_SHELLITEM|<o PyIShellItem> + IShellItem *buf; + if (!PyCom_InterfaceFromPyObject(ob, IID_IShellItem, (void **)&buf, FALSE)) + return NULL; + PY_INTERFACE_PRECALL; + SHAddToRecentDocs(flags, buf); + buf->Release(); + PY_INTERFACE_POSTCALL; + break; + } +#endif // WINVER + default: + PyErr_SetString(PyExc_NotImplementedError, "SHARD value not supported"); + return NULL; + } Py_INCREF(Py_None); return Py_None; } - // @pymethod |shell|SHEmptyRecycleBin|Empties the recycle bin on the specified drive. static PyObject *PySHEmptyRecycleBin(PyObject *self, PyObject *args) { @@ -2806,7 +2939,7 @@ PCIDLIST_ABSOLUTE_ARRAY pidls = NULL; IShellItemArray *iret = NULL; UINT npidls; - if(!PyArg_ParseTuple(args, "O:SHCreateShellItemArray", &obpidls)) + if(!PyArg_ParseTuple(args, "O:SHCreateShellItemArrayFromIDLists", &obpidls)) return NULL; // @pyparm [<o PyIDL>, ...]|pidls||A sequence of absolute IDLs. if (!PyObject_AsPIDLArray(obpidls, &npidls, &pidls)) @@ -2830,7 +2963,7 @@ return ret; } -// @pymethod <o PyIUnknown>|shell|SHCreateShellItemArrayFromShellItem| +// @pymethod <o PyIShellItemArray>|shell|SHCreateShellItemArrayFromShellItem|Creates an item array containing a single item static PyObject *PySHCreateShellItemArrayFromShellItem(PyObject *self, PyObject *args) { // @comm This function is only available on Vista and later; a @@ -2838,35 +2971,28 @@ if (pfnSHCreateShellItemArrayFromShellItem==NULL) return PyCom_BuildPyException(E_NOTIMPL); - PyObject *ret = NULL; PyObject *obsi; - PyObject *obiid = Py_None; IShellItem *isi = NULL; IID iid = IID_IShellItemArray; void *iret = NULL; - if(!PyArg_ParseTuple(args, "O|O:SHCreateShellItemArrayFromShellItem", &obsi, &obiid)) + if(!PyArg_ParseTuple(args, "O|O&:SHCreateShellItemArrayFromShellItem", &obsi, + PyWinObject_AsIID, &iid)) return NULL; // @pyparm <o PyIShellItem>|si||A shell item if (!PyCom_InterfaceFromPyInstanceOrObject(obsi, IID_IShellItem, (void **)&isi, FALSE/* bNoneOK */)) - goto done; - // @pyparm <o PyIID>|iid|IID_IShellItemArray|The IID to query for - if (obiid != Py_None && !PyWinObject_AsIID(obiid, &iid)) - goto done; + return NULL; + // @pyparm <o PyIID>|riid|IID_IShellItemArray|The interface to return HRESULT hr; { PY_INTERFACE_PRECALL; hr = (*pfnSHCreateShellItemArrayFromShellItem)(isi, iid, &iret); + isi->Release(); PY_INTERFACE_POSTCALL; } - if (FAILED(hr)) { - PyCom_BuildPyException(hr); - goto done; - } + if (FAILED(hr)) + return PyCom_BuildPyException(hr); // ref on view consumed by ret object. - ret = PyCom_PyObjectFromIUnknown((IUnknown *)iret, iid, FALSE); -done: - PYCOM_RELEASE(isi); - return ret; + return PyCom_PyObjectFromIUnknown((IUnknown *)iret, iid, FALSE); } // @pymethod <o PyIShellItem>|shell|SHCreateItemFromIDList|Creates and initializes a Shell item @@ -2881,7 +3007,7 @@ PyObject *obpidl; IID iid = IID_IShellItem; // @pyparm <o PyIDL>|pidl||An absolute item identifier list - // @pyparm <o PyIID>|iid|IID_IShellItem|The interface to create + // @pyparm <o PyIID>|riid|IID_IShellItem|The interface to create if(!PyArg_ParseTuple(args, "O|O&:SHCreateItemFromIDList", &obpidl, PyWinObject_AsIID, &iid)) return NULL; PIDLIST_ABSOLUTE pidl; @@ -2916,7 +3042,7 @@ PyObject *obname, *obctx, *obiid; // @pyparm str|name||The display name of the item to create, eg a file path // @pyparm <o PyIBindCtx>|ctx||Bind context, can be None - // @pyparm <o PyIID>|iid||The interface to create, IID_IShellItem or IID_IShellItem2 + // @pyparm <o PyIID>|riid||The interface to create, IID_IShellItem or IID_IShellItem2 if(!PyArg_ParseTuple(args, "OOO:SHCreateItemFromParsingName", &obname, &obctx, &obiid)) return NULL; @@ -2965,10 +3091,10 @@ PyObject *ret = NULL; PyObject *obname, *obctx, *obiid, *obparent; - // @pyparm <o PyIShellItem>|parent|| - // @pyparm unicode|name|| - // @pyparm <o PyIBindCtx>|ctx|| - // @pyparm <o PyIID>|iid|| + // @pyparm <o PyIShellItem>|Parent||Shell item interface on the parent folder + // @pyparm str|Name||Relative name of an item within the parent folder + // @pyparm <o PyIBindCtx>|ctx||Bind context for parsing, can be None + // @pyparm <o PyIID>|riid||The interface to return, IID_IShellItem or IID_IShellItem2 if(!PyArg_ParseTuple(args, "OOOO:SHCreateItemFromRelativeName", &obparent, &obname, &obctx, &obiid)) return NULL; |
From: <pyw...@li...> - 2012-09-30 21:39:37
|
changeset 789a2c39b4fa in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=789a2c39b4fa summary: Add IShellLibrary to win32com.shell diffstat: CHANGES.txt | 3 +- com/win32comext/shell/shellcon.py | 20 + com/win32comext/shell/src/PyIShellLibrary.cpp | 475 ++++++++++++++++++++++++++ com/win32comext/shell/src/PyIShellLibrary.h | 41 ++ com/win32comext/shell/src/shell.cpp | 46 ++- setup.py | 1 + 6 files changed, 581 insertions(+), 5 deletions(-) diffs (truncated from 657 to 300 lines): diff -r 7b2f5cfd84bd -r 789a2c39b4fa CHANGES.txt --- a/CHANGES.txt Sat Sep 29 17:03:38 2012 -0400 +++ b/CHANGES.txt Sun Sep 30 17:38:34 2012 -0400 @@ -37,7 +37,8 @@ * win32com.shell - added function SHCreateStreamOnFileEx and interfaces IShellItem2, IEnumShellItems, IApplicationDocumentLists, IApplicationDestinations, ITaskbarList, IEnumObjects, - IKnownFolder, and IKnownFolderManager + IKnownFolder, IKnownFolderManager, IObjectArray, IObjectCollection, + ICustomDestinationList, and IShellLibrary * win32com.propsys - Many Property System interfaces and functions added diff -r 7b2f5cfd84bd -r 789a2c39b4fa com/win32comext/shell/shellcon.py --- a/com/win32comext/shell/shellcon.py Sat Sep 29 17:03:38 2012 -0400 +++ b/com/win32comext/shell/shellcon.py Sun Sep 30 17:38:34 2012 -0400 @@ -1334,3 +1334,23 @@ ## KNOWNDESTCATEGORY used with ICustomDestinationList.AppendKnownCategory KDC_FREQUENT = 1 KDC_RECENT = 2 + +## LIBRARYFOLDERFILTER used with IShellLibrary.GetFolders +LFF_FORCEFILESYSTEM = 1 +LFF_STORAGEITEMS = 2 +LFF_ALLITEMS = 3 + +## DEFAULTSAVEFOLDERTYPE used with IShellLibrary.Get/SetDefaultSaveFolder +DSFT_DETECT = 1 +DSFT_PRIVATE = 2 +DSFT_PUBLIC = 3 + +## LIBRARYOPTIONFLAGS used with IShellLibrary.Get/SetOptions +LOF_DEFAULT = 0 +LOF_PINNEDTONAVPANE = 1 +LOF_MASK_ALL = 1 + +## LIBRARYSAVEFLAGS Used with PyIShellLibrary.Save +LSF_FAILIFTHERE = 0 +LSF_OVERRIDEEXISTING = 1 +LSF_MAKEUNIQUENAME = 2 diff -r 7b2f5cfd84bd -r 789a2c39b4fa com/win32comext/shell/src/PyIShellLibrary.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/win32comext/shell/src/PyIShellLibrary.cpp Sun Sep 30 17:38:34 2012 -0400 @@ -0,0 +1,475 @@ +// This file implements the IShellLibrary Interface for Python. +// Generated by makegw.py + +#include "shell_pch.h" + +// Requires Windows 7 SDK to build +#if WINVER >= 0x0601 + +#include "PyIShellLibrary.h" + +// @doc - This file contains autoduck documentation +// --------------------------------------------------- +// +// Interface Implementation + +PyIShellLibrary::PyIShellLibrary(IUnknown *pdisp): + PyIUnknown(pdisp) +{ + ob_type = &type; +} + +PyIShellLibrary::~PyIShellLibrary() +{ +} + +/* static */ IShellLibrary *PyIShellLibrary::GetI(PyObject *self) +{ + return (IShellLibrary *)PyIUnknown::GetI(self); +} + +// @pymethod |PyIShellLibrary|LoadLibraryFromItem|Loads an existing library file +PyObject *PyIShellLibrary::LoadLibraryFromItem(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + IShellItem *Library; + PyObject *obLibrary; + DWORD Mode; + // @pyparm <o PyIShellItem>|Library||Shell item interface representing the library file + // @pyparm int|Mode||Access mode, combination of storagecon.STGM_* flags + if ( !PyArg_ParseTuple(args, "Ok:LoadLibraryFromItem", &obLibrary, &Mode) ) + return NULL; + if (!PyCom_InterfaceFromPyObject(obLibrary, IID_IShellItem, (void **)&Library, FALSE)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->LoadLibraryFromItem(Library, Mode); + Library->Release(); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod |PyIShellLibrary|LoadLibraryFromKnownFolder|Initializes library from a known folder +PyObject *PyIShellLibrary::LoadLibraryFromKnownFolder(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + IID Library; + DWORD Mode; + // @pyparm <o PyIID>|Library||Known folder id, shell.FOLDERID_* + // @pyparm int|Mode||Access mode, combination of storagecon.STGM_* flags + if ( !PyArg_ParseTuple(args, "O&k:LoadLibraryFromKnownFolder", + PyWinObject_AsIID, &Library, &Mode)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->LoadLibraryFromKnownFolder(Library, Mode); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod |PyIShellLibrary|AddFolder|Includes a folder +PyObject *PyIShellLibrary::AddFolder(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + IShellItem *Location; + PyObject *obLocation; + // @pyparm <o PyIShellItem>|Location||Shell item interface representing the folder + if ( !PyArg_ParseTuple(args, "O:AddFolder", &obLocation)) + return NULL; + if (!PyCom_InterfaceFromPyObject(obLocation, IID_IShellItem, (void **)&Location, FALSE)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->AddFolder(Location); + Location->Release(); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + Py_INCREF(Py_None); + return Py_None; + +} + +// @pymethod |PyIShellLibrary|RemoveFolder|Removes a folder +PyObject *PyIShellLibrary::RemoveFolder(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + IShellItem *Location; + PyObject *obLocation; + // @pyparm <o PyIShellItem>|Location||Shell item interface representing the folder + if ( !PyArg_ParseTuple(args, "O:RemoveFolder", &obLocation)) + return NULL; + if (!PyCom_InterfaceFromPyObject(obLocation, IID_IShellItem, (void **)&Location, FALSE)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->RemoveFolder(Location); + Location->Release(); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod <o PyIShellItemArray>|PyIShellLibrary|GetFolders|Retrieves a collection of folders in the library +PyObject *PyIShellLibrary::GetFolders(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + // @pyparm int|Filter|LFF_ALLITEMS|Specifies what types of folder to return (shellcon.LFF_*) + // @pyparm <o PyIID>|riid|IID_IShellItemArray|The interface to return, IObjectCollection and IObjectArray also accepted. + LIBRARYFOLDERFILTER Filter = LFF_ALLITEMS; + IID riid = IID_IShellItemArray; + void *pv; + if ( !PyArg_ParseTuple(args, "|iO&:GetFolders", &Filter, PyWinObject_AsIID, &riid)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->GetFolders(Filter, riid, &pv); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + return PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE); +} + +// @pymethod <o PyIShellItem>|PyIShellLibrary|ResolveFolder|Attempts to locate a folder that has been moved or renamed +PyObject *PyIShellLibrary::ResolveFolder(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + IShellItem *FolderToResolve; + PyObject *obFolderToResolve; + DWORD Timeout; + IID riid = IID_IShellItem; + // @pyparm <o PyIShellItem>|FolderToResolve||Library item whose location has changed + // @pyparm int|Timeout||Max search time, specified in milliseconds + // @pyparm <o PyIID>|riid|IID_IShellItem|The interface to return + if (!PyArg_ParseTuple(args, "Ok|O&:ResolveFolder", + &obFolderToResolve, &Timeout, + PyWinObject_AsIID, &riid)) + return NULL; + if (!PyCom_InterfaceFromPyObject(obFolderToResolve, IID_IShellItem, (void **)&FolderToResolve, FALSE)) + return NULL; + + void *pv; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->ResolveFolder(FolderToResolve, Timeout, riid, &pv ); + FolderToResolve->Release(); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + return PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE); +} + +// @pymethod <o PyIShellItem>|PyIShellLibrary|GetDefaultSaveFolder|Returns the default folder in which new items are saved +PyObject *PyIShellLibrary::GetDefaultSaveFolder(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + DEFAULTSAVEFOLDERTYPE Type = DSFT_DETECT; + IID riid = IID_IShellItem; + // @pyparm int|Type|DSFT_DETECT|Specifies whether to return public or private save location, shellcon.DSFT_* + // @pyparm <o PyIID>|riid|IID_IShellItem|The interface to return + if ( !PyArg_ParseTuple(args, "|iO&:GetDefaultSaveFolder", &Type, PyWinObject_AsIID, &riid)) + return NULL; + + void *pv; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->GetDefaultSaveFolder(Type, riid, &pv); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + return PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE); +} + +// @pymethod |PyIShellLibrary|SetDefaultSaveFolder|Sets the default save location +PyObject *PyIShellLibrary::SetDefaultSaveFolder(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + DEFAULTSAVEFOLDERTYPE Type; + IShellItem *SaveFolder; + PyObject *obSaveFolder; + // @pyparm int|Type||Specifies public or private save location, shellcon.DSFT_* + // @pyparm <o PyIShellItem>|SaveFolder||New default location, must be in the library + if (!PyArg_ParseTuple(args, "iO:SetDefaultSaveFolder", &Type, &obSaveFolder)) + return NULL; + if (!PyCom_InterfaceFromPyObject(obSaveFolder, IID_IShellItem, (void **)&SaveFolder, FALSE)) + return NULL; + + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->SetDefaultSaveFolder(Type, SaveFolder); + SaveFolder->Release(); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod int|PyIShellLibrary|GetOptions|Retrieves library option flags +// @rdesc Returns a combination of shellcon.LOF_* flags +PyObject *PyIShellLibrary::GetOptions(PyObject *self, PyObject *args) +{ + IShellLibrary *pISL = GetI(self); + if ( pISL == NULL ) + return NULL; + LIBRARYOPTIONFLAGS Options; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pISL->GetOptions(&Options); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); + return PyInt_FromLong(Options); +} |
From: <pyw...@li...> - 2012-09-29 21:05:54
|
changeset 7b2f5cfd84bd in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=7b2f5cfd84bd summary: Add interfaces used to create a customized jump list (IObjectArray, IObjectCollection, ICustomDestinationList) diffstat: com/win32comext/shell/shellcon.py | 5 +- com/win32comext/shell/src/PyICustomDestinationList.cpp | 255 +++++++++++++++++ com/win32comext/shell/src/PyICustomDestinationList.h | 33 ++ com/win32comext/shell/src/PyIObjectArray.cpp | 85 +++++ com/win32comext/shell/src/PyIObjectArray.h | 26 + com/win32comext/shell/src/PyIObjectCollection.cpp | 136 +++++++++ com/win32comext/shell/src/PyIObjectCollection.h | 28 + com/win32comext/shell/src/PyITaskbarList.cpp | 2 +- com/win32comext/shell/src/shell.cpp | 13 +- setup.py | 3 + 10 files changed, 581 insertions(+), 5 deletions(-) diffs (truncated from 668 to 300 lines): diff -r 32720ca1acc2 -r 7b2f5cfd84bd com/win32comext/shell/shellcon.py --- a/com/win32comext/shell/shellcon.py Thu Sep 27 02:20:00 2012 -0400 +++ b/com/win32comext/shell/shellcon.py Sat Sep 29 17:03:38 2012 -0400 @@ -1327,9 +1327,10 @@ KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200 KF_FLAG_SIMPLE_IDLIST = 0x00000100 - - ## APPDOCLISTTYPE, used with IApplicationDocumentLists.GetList ADLT_RECENT = 0 ADLT_FREQUENT = 1 +## KNOWNDESTCATEGORY used with ICustomDestinationList.AppendKnownCategory +KDC_FREQUENT = 1 +KDC_RECENT = 2 diff -r 32720ca1acc2 -r 7b2f5cfd84bd com/win32comext/shell/src/PyICustomDestinationList.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/win32comext/shell/src/PyICustomDestinationList.cpp Sat Sep 29 17:03:38 2012 -0400 @@ -0,0 +1,255 @@ +// This file implements the ICustomDestinationList Interface for Python. +// Generated by makegw.py + +#include "shell_pch.h" + +// Requires Windows 7 SDK to build +#if WINVER >= 0x0601 + +#include "PyICustomDestinationList.h" + +// @doc - This file contains autoduck documentation +// --------------------------------------------------- +// +// Interface Implementation + +PyICustomDestinationList::PyICustomDestinationList(IUnknown *pdisp): + PyIUnknown(pdisp) +{ + ob_type = &type; +} + +PyICustomDestinationList::~PyICustomDestinationList() +{ +} + +/* static */ ICustomDestinationList *PyICustomDestinationList::GetI(PyObject *self) +{ + return (ICustomDestinationList *)PyIUnknown::GetI(self); +} + +// @pymethod |PyICustomDestinationList|SetAppID|Specifies the taskbar identifier for the jump list +// @comm Only needed if the calling app doesn't use the system-assigned default +PyObject *PyICustomDestinationList::SetAppID(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + TmpWCHAR AppID; + PyObject *obAppID; + // @pyparm str|AppID||The taskbar identifier of the application + if ( !PyArg_ParseTuple(args, "O:SetAppID", &obAppID) ) + return NULL; + if (!PyWinObject_AsWCHAR(obAppID, &AppID )) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->SetAppID(AppID ); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod int, <o PyIObjectArray>|PyICustomDestinationList|BeginList|Clears the jump list and prepares it to be repopulated +// @rdesc Returns the number of slots and a collection of all destinations removed from the jump list +PyObject *PyICustomDestinationList::BeginList(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + UINT slots; + REFIID riid = IID_IObjectArray; + // @pyparm <o PyIID>|riid|IID_IObjectArray|The interface to return + void *pv; + if ( !PyArg_ParseTuple(args, "|O&:BeginList", PyWinObject_AsIID, &riid)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->BeginList(&slots, riid, &pv); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + return Py_BuildValue("kN", slots, PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE)); +} + +// @pymethod |PyICustomDestinationList|AppendCategory|Adds a custom category to the jump list +PyObject *PyICustomDestinationList::AppendCategory(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + + TmpWCHAR Category; + PyObject *obCategory, *obItems; + IObjectArray *Items; + // @pyparm str|Category||Display name of the category, can also be a dll and resource id for localization + // @pyparm <o PyIObjectArray>|Items||Collection of IShellItem and/or IShellLink interfaces + if ( !PyArg_ParseTuple(args, "OO:AppendCategory", &obCategory, &obItems)) + return NULL; + if (!PyWinObject_AsWCHAR(obCategory, &Category, FALSE)) + return NULL; + if (!PyCom_InterfaceFromPyInstanceOrObject(obItems, IID_IObjectArray, (void **)&Items, FALSE)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->AppendCategory(Category, Items); + Items->Release(); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod |PyICustomDestinationList|AppendKnownCategory|Adds one of the predefined categories to the custom list +PyObject *PyICustomDestinationList::AppendKnownCategory(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + KNOWNDESTCATEGORY category; + // @pyparm int|Category||shellcon.KDC_RECENT or KDC_FREQUENT + if ( !PyArg_ParseTuple(args, "i:AppendKnownCategory", &category) ) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->AppendKnownCategory( category ); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod |PyICustomDestinationList|AddUserTasks|Sets the entries shown in the Tasks category +PyObject *PyICustomDestinationList::AddUserTasks(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + PyObject *obItems; + IObjectArray *Items; + // @pyparm <o PyIObjectArray>|Items||Collection of <o PyIShellItem> and/or <o PyIShellLink> interfaces + if ( !PyArg_ParseTuple(args, "O:AddUserTasks", &obItems)) + return NULL; + if (!PyCom_InterfaceFromPyInstanceOrObject(obItems, IID_IObjectArray, (void **)&Items, FALSE)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->AddUserTasks(Items); + Items->Release(); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod |PyICustomDestinationList|CommitList|Finalizes changes. +PyObject *PyICustomDestinationList::CommitList(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->CommitList( ); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod <o PyIObjectArray>|PyICustomDestinationList|GetRemovedDestinations|Returns all the items removed from the jump list +PyObject *PyICustomDestinationList::GetRemovedDestinations(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + // @pyparm <o PyIID>|riid|IID_IObjectArray|The interface to return + REFIID riid = IID_IObjectArray; + void *pv; + if ( !PyArg_ParseTuple(args, "|O&:GetRemovedDestinations", PyWinObject_AsIID, &riid)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->GetRemovedDestinations( riid, &pv ); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + return PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE); +} + +// @pymethod |PyICustomDestinationList|DeleteList|Removes any customization, leaving only the system-maintained Recent and Frequent lists +PyObject *PyICustomDestinationList::DeleteList(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + TmpWCHAR AppID; + PyObject *obAppID = Py_None; + // @pyparm str|AppID|None|The taskbar identifier of the application + if ( !PyArg_ParseTuple(args, "|O:DeleteList", &obAppID)) + return NULL; + if (!PyWinObject_AsWCHAR(obAppID, &AppID, TRUE)) + return NULL; + + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->DeleteList(AppID); + PY_INTERFACE_POSTCALL; + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod |PyICustomDestinationList|AbortList|Discards all changes +PyObject *PyICustomDestinationList::AbortList(PyObject *self, PyObject *args) +{ + ICustomDestinationList *pICDL = GetI(self); + if ( pICDL == NULL ) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pICDL->AbortList( ); + PY_INTERFACE_POSTCALL; + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList ); + Py_INCREF(Py_None); + return Py_None; +} + +// @object PyICustomDestinationList|Interface used to customize an application's jump list +// @comm Requires Windows 7 or later +static struct PyMethodDef PyICustomDestinationList_methods[] = +{ + { "SetAppID", PyICustomDestinationList::SetAppID, 1 }, // @pymeth SetAppID|Specifies the taskbar identifier for the jump list + { "BeginList", PyICustomDestinationList::BeginList, 1 }, // @pymeth BeginList|Clears the jump list and prepares it to be repopulated + { "AppendCategory", PyICustomDestinationList::AppendCategory, 1 }, // @pymeth AppendCategory|Adds a custom category to the jump list + { "AppendKnownCategory", PyICustomDestinationList::AppendKnownCategory, 1 }, // @pymeth AppendKnownCategory|Adds one of the predefined categories to the custom list + { "AddUserTasks", PyICustomDestinationList::AddUserTasks, 1 }, // @pymeth AddUserTasks|Sets the entries shown in the Tasks category + { "CommitList", PyICustomDestinationList::CommitList, METH_NOARGS }, // @pymeth CommitList|Finalizes changes + { "GetRemovedDestinations", PyICustomDestinationList::GetRemovedDestinations, 1 }, // @pymeth GetRemovedDestinations|Returns all the items removed from the jump list + { "DeleteList", PyICustomDestinationList::DeleteList, 1 }, // @pymeth DeleteList|Removes any customization, leaving only the system-maintained Recent and Frequent lists + { "AbortList", PyICustomDestinationList::AbortList, METH_NOARGS }, // @pymeth AbortList|Discards all changes + { NULL } +}; + +PyComTypeObject PyICustomDestinationList::type("PyICustomDestinationList", + &PyIUnknown::type, + sizeof(PyICustomDestinationList), + PyICustomDestinationList_methods, + GET_PYCOM_CTOR(PyICustomDestinationList)); + +#endif // WINVER diff -r 32720ca1acc2 -r 7b2f5cfd84bd com/win32comext/shell/src/PyICustomDestinationList.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/win32comext/shell/src/PyICustomDestinationList.h Sat Sep 29 17:03:38 2012 -0400 @@ -0,0 +1,33 @@ +// This file declares the ICustomDestinationList Interface for Python. +// Generated by makegw.py +// --------------------------------------------------- +// +// Interface Declaration + +// Requires Windows 7 SDK to build +#if WINVER >= 0x0601 + +class PyICustomDestinationList : public PyIUnknown +{ +public: + MAKE_PYCOM_CTOR(PyICustomDestinationList); + static ICustomDestinationList *GetI(PyObject *self); + static PyComTypeObject type; + + // The Python methods + static PyObject *SetAppID(PyObject *self, PyObject *args); + static PyObject *BeginList(PyObject *self, PyObject *args); + static PyObject *AppendCategory(PyObject *self, PyObject *args); + static PyObject *AppendKnownCategory(PyObject *self, PyObject *args); |
From: <pyw...@li...> - 2012-09-27 06:25:19
|
changeset 32720ca1acc2 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=32720ca1acc2 summary: Add IApplicationDocumentLists, IApplicationDestinations, ITaskbarList, and IEnumObjects diffstat: CHANGES.txt | 8 +- com/win32comext/shell/shellcon.py | 7 + com/win32comext/shell/src/PyIApplicationDestinations.cpp | 113 +++++++ com/win32comext/shell/src/PyIApplicationDestinations.h | 26 + com/win32comext/shell/src/PyIApplicationDocumentLists.cpp | 96 ++++++ com/win32comext/shell/src/PyIApplicationDocumentLists.h | 26 + com/win32comext/shell/src/PyIEnumObjects.cpp | 163 +++++++++++ com/win32comext/shell/src/PyIEnumObjects.h | 24 + com/win32comext/shell/src/PyIShellBrowser.cpp | 4 +- com/win32comext/shell/src/PyITaskbarList.cpp | 144 ++++++++++ com/win32comext/shell/src/PyITaskbarList.h | 24 + com/win32comext/shell/src/shell.cpp | 198 +++++++------ setup.py | 4 + 13 files changed, 736 insertions(+), 101 deletions(-) diffs (truncated from 1074 to 300 lines): diff -r ec95c2687fb1 -r 32720ca1acc2 CHANGES.txt --- a/CHANGES.txt Thu Sep 27 01:05:46 2012 -0400 +++ b/CHANGES.txt Thu Sep 27 02:20:00 2012 -0400 @@ -35,7 +35,9 @@ * Python 3.3 version is built with VS2010. * win32com.shell - added function SHCreateStreamOnFileEx and - interfaces IShellItem2, IEnumShellItems + interfaces IShellItem2, IEnumShellItems, IApplicationDocumentLists, + IApplicationDestinations, ITaskbarList, IEnumObjects, + IKnownFolder, and IKnownFolderManager * win32com.propsys - Many Property System interfaces and functions added @@ -45,6 +47,10 @@ Fix iteration of objects that don't declare an enumerator in their typelib Validate syntax of constants written to makepy generated files +* win32file - Add GetFileInformationByHandleEx + +* win32api - Allow UpdateResource to remove a resource + Since build 216: ---------------- * ISAPI extension works with Python 3.x diff -r ec95c2687fb1 -r 32720ca1acc2 com/win32comext/shell/shellcon.py --- a/com/win32comext/shell/shellcon.py Thu Sep 27 01:05:46 2012 -0400 +++ b/com/win32comext/shell/shellcon.py Thu Sep 27 02:20:00 2012 -0400 @@ -1326,3 +1326,10 @@ KF_FLAG_DEFAULT_PATH = 0x00000400 KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200 KF_FLAG_SIMPLE_IDLIST = 0x00000100 + + + +## APPDOCLISTTYPE, used with IApplicationDocumentLists.GetList +ADLT_RECENT = 0 +ADLT_FREQUENT = 1 + diff -r ec95c2687fb1 -r 32720ca1acc2 com/win32comext/shell/src/PyIApplicationDestinations.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/win32comext/shell/src/PyIApplicationDestinations.cpp Thu Sep 27 02:20:00 2012 -0400 @@ -0,0 +1,113 @@ +// This file implements the IApplicationDestinations Interface for Python. +// Generated by makegw.py + +#include "shell_pch.h" + +// Requires Windows 7 SDK to build +#if WINVER >= 0x0601 + +#include "PyIApplicationDestinations.h" + +// @doc - This file contains autoduck documentation +// --------------------------------------------------- +// +// Interface Implementation + +PyIApplicationDestinations::PyIApplicationDestinations(IUnknown *pdisp): + PyIUnknown(pdisp) +{ + ob_type = &type; +} + +PyIApplicationDestinations::~PyIApplicationDestinations() +{ +} + +/* static */ IApplicationDestinations *PyIApplicationDestinations::GetI(PyObject *self) +{ + return (IApplicationDestinations *)PyIUnknown::GetI(self); +} + +// @pymethod |PyIApplicationDestinations|SetAppID|Specifies the application whose jump list is to be accessed +// @comm This method is only needed if the application sets its own taskbar identifier +PyObject *PyIApplicationDestinations::SetAppID(PyObject *self, PyObject *args) +{ + IApplicationDestinations *pIAD = GetI(self); + if ( pIAD == NULL ) + return NULL; + // @pyparm str|AppID||Taskbar identifier for the application + PyObject *obappid; + TmpWCHAR appid; + if ( !PyArg_ParseTuple(args, "O:SetAppID", &obappid) ) + return NULL; + if (!PyWinObject_AsWCHAR(obappid, &appid, FALSE)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIAD->SetAppID(appid); + PY_INTERFACE_POSTCALL; + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIAD, IID_IApplicationDestinations); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod |PyIApplicationDestinations|RemoveDestination|Removes a single entry from the jump lists +// @comm Does not remove pinned items +PyObject *PyIApplicationDestinations::RemoveDestination(PyObject *self, PyObject *args) +{ + IApplicationDestinations *pIAD = GetI(self); + if ( pIAD == NULL ) + return NULL; + IUnknown *punk; + PyObject *obpunk; + // @pyparm <o PyIUnknown>|punk||IShellItem or IShellLink representing an item in the application's jump list + if ( !PyArg_ParseTuple(args, "O:RemoveDestination", &obpunk)) + return NULL; + if (!PyCom_InterfaceFromPyObject(obpunk, IID_IUnknown, (void **)&punk, FALSE)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIAD->RemoveDestination( punk ); + punk->Release(); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIAD, IID_IApplicationDestinations ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod |PyIApplicationDestinations|RemoveAllDestinations|Removes all Recent and Frequent jump list entries +PyObject *PyIApplicationDestinations::RemoveAllDestinations(PyObject *self, PyObject *args) +{ + IApplicationDestinations *pIAD = GetI(self); + if ( pIAD == NULL ) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIAD->RemoveAllDestinations( ); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIAD, IID_IApplicationDestinations ); + Py_INCREF(Py_None); + return Py_None; +} + +// @object PyIApplicationDestinations|Allows an application to removed items from its jump lists +// @comm Available on Windows 7 and later +static struct PyMethodDef PyIApplicationDestinations_methods[] = +{ + { "SetAppID", PyIApplicationDestinations::SetAppID, 1 }, // @pymeth SetAppID|Specifies the application whose jump list is to be accessed + { "RemoveDestination", PyIApplicationDestinations::RemoveDestination, 1 }, // @pymeth RemoveDestination|Removes a single entry from the jump list + { "RemoveAllDestinations", PyIApplicationDestinations::RemoveAllDestinations, METH_NOARGS }, // @pymeth RemoveAllDestinations|Removes all Recent and Frequent jump list entries + { NULL } +}; + +PyComTypeObject PyIApplicationDestinations::type("PyIApplicationDestinations", + &PyIUnknown::type, + sizeof(PyIApplicationDestinations), + PyIApplicationDestinations_methods, + GET_PYCOM_CTOR(PyIApplicationDestinations)); +#endif // WINVER \ No newline at end of file diff -r ec95c2687fb1 -r 32720ca1acc2 com/win32comext/shell/src/PyIApplicationDestinations.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/win32comext/shell/src/PyIApplicationDestinations.h Thu Sep 27 02:20:00 2012 -0400 @@ -0,0 +1,26 @@ +// Requires Windows 7 SDK to build +#if WINVER >= 0x0601 +// This file declares the IApplicationDestinations Interface for Python. +// Generated by makegw.py +// --------------------------------------------------- +// +// Interface Declaration + +class PyIApplicationDestinations : public PyIUnknown +{ +public: + MAKE_PYCOM_CTOR(PyIApplicationDestinations); + static IApplicationDestinations *GetI(PyObject *self); + static PyComTypeObject type; + + // The Python methods + static PyObject *SetAppID(PyObject *self, PyObject *args); + static PyObject *RemoveDestination(PyObject *self, PyObject *args); + static PyObject *RemoveAllDestinations(PyObject *self, PyObject *args); + +protected: + PyIApplicationDestinations(IUnknown *pdisp); + ~PyIApplicationDestinations(); +}; + +#endif // WINVER \ No newline at end of file diff -r ec95c2687fb1 -r 32720ca1acc2 com/win32comext/shell/src/PyIApplicationDocumentLists.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/win32comext/shell/src/PyIApplicationDocumentLists.cpp Thu Sep 27 02:20:00 2012 -0400 @@ -0,0 +1,96 @@ +// This file implements the IApplicationDocumentLists Interface for Python. +// Generated by makegw.py + +#include "shell_pch.h" + +// Requires Windows 7 SDK to build +#if WINVER >= 0x0601 + +#include "PyIApplicationDocumentLists.h" + +// @doc - This file contains autoduck documentation +// --------------------------------------------------- +// +// Interface Implementation + +PyIApplicationDocumentLists::PyIApplicationDocumentLists(IUnknown *pdisp): + PyIUnknown(pdisp) +{ + ob_type = &type; +} + +PyIApplicationDocumentLists::~PyIApplicationDocumentLists() +{ +} + +/* static */ IApplicationDocumentLists *PyIApplicationDocumentLists::GetI(PyObject *self) +{ + return (IApplicationDocumentLists *)PyIUnknown::GetI(self); +} + +// @pymethod |PyIApplicationDocumentLists|SetAppID|Specifies the application whose jump list is to be accessed +// @comm This method is only needed if the application sets its own taskbar identifier +PyObject *PyIApplicationDocumentLists::SetAppID(PyObject *self, PyObject *args) +{ + IApplicationDocumentLists *pIADL = GetI(self); + if ( pIADL == NULL ) + return NULL; + // @pyparm str|AppID||Taskbar identifier for the application + PyObject *obappid; + TmpWCHAR appid; + if ( !PyArg_ParseTuple(args, "O:SetAppID", &obappid) ) + return NULL; + if (!PyWinObject_AsWCHAR(obappid, &appid, FALSE)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIADL->SetAppID(appid); + PY_INTERFACE_POSTCALL; + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIADL, IID_IApplicationDocumentLists ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod <o PyIEnumObjects>|PyIApplicationDocumentLists|GetList|Retrieves a list of items in a jump list +PyObject *PyIApplicationDocumentLists::GetList(PyObject *self, PyObject *args) +{ + IApplicationDocumentLists *pIADL = GetI(self); + if ( pIADL == NULL ) + return NULL; + // @pyparm int|ListType||Type of document list to return, shellcon.ADLT_RECENT or ADLT_FREQUENT + // @pyparm int|ItemsDesired|0|Number of items to return, use 0 for all available + // @pyparm <o PyIID>|riid|IID_IEnumObjects|The interface to return, IID_IEnumObjects or IID_IObjectArray + APPDOCLISTTYPE listtype; + IID riid = IID_IEnumObjects; + void *ppv; + UINT cItemsDesired = 0; + if ( !PyArg_ParseTuple(args, "i|kO&:GetList", &listtype, &cItemsDesired, + PyWinObject_AsIID, &riid)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIADL->GetList( listtype, cItemsDesired, riid, &ppv ); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIADL, IID_IApplicationDocumentLists ); + return PyCom_PyObjectFromIUnknown((IUnknown *)ppv, riid, FALSE); +} + +// @object PyIApplicationDocumentLists|Interface used to retrieve the jump lists for an application +// @comm Available on Windows 7 and later +static struct PyMethodDef PyIApplicationDocumentLists_methods[] = +{ + { "SetAppID", PyIApplicationDocumentLists::SetAppID, 1 }, // @pymeth SetAppID|Specifies the application whose jump list is to be accessed + { "GetList", PyIApplicationDocumentLists::GetList, 1 }, // @pymeth GetList|Retrieves a list of items in a jump list + { NULL } +}; + +PyComTypeObject PyIApplicationDocumentLists::type("PyIApplicationDocumentLists", + &PyIUnknown::type, + sizeof(PyIApplicationDocumentLists), + PyIApplicationDocumentLists_methods, + GET_PYCOM_CTOR(PyIApplicationDocumentLists)); + +#endif // WINVER \ No newline at end of file diff -r ec95c2687fb1 -r 32720ca1acc2 com/win32comext/shell/src/PyIApplicationDocumentLists.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/win32comext/shell/src/PyIApplicationDocumentLists.h Thu Sep 27 02:20:00 2012 -0400 @@ -0,0 +1,26 @@ +// Requires Windows 7 SDK to build +#if WINVER >= 0x0601 + +// This file declares the IApplicationDocumentLists Interface for Python. +// Generated by makegw.py +// --------------------------------------------------- +// |
From: <pyw...@li...> - 2012-09-27 05:30:15
|
changeset ec95c2687fb1 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=ec95c2687fb1 summary: Allow UpdateResource to accept None to delete resource diffstat: win32/src/win32apimodule.cpp | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 57773ea432bb -r ec95c2687fb1 win32/src/win32apimodule.cpp --- a/win32/src/win32apimodule.cpp Wed Sep 26 23:11:32 2012 -0400 +++ b/win32/src/win32apimodule.cpp Thu Sep 27 01:05:46 2012 -0400 @@ -5364,7 +5364,7 @@ if (PyWinObject_AsHANDLE(obhUpdate, (HANDLE *)&hUpdate) &&PyWinObject_AsResourceIdW(obType, &lpType) &&PyWinObject_AsResourceIdW(obName, &lpName) - &&PyWinObject_AsReadBuffer(obData, &lpData, &cbData, FALSE)){ + &&PyWinObject_AsReadBuffer(obData, &lpData, &cbData, TRUE)){ if (UpdateResourceW(hUpdate, lpType, lpName, wLanguage, lpData, cbData)){ Py_INCREF(Py_None); ret=Py_None; |
From: <pyw...@li...> - 2012-09-27 03:15:00
|
changeset 57773ea432bb in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=57773ea432bb summary: Add GetFileInformationByHandleEx diffstat: win32/src/win32file.i | 268 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 257 insertions(+), 11 deletions(-) diffs (truncated from 340 to 300 lines): diff -r 125b96a72be7 -r 57773ea432bb win32/src/win32file.i --- a/win32/src/win32file.i Mon Sep 24 10:21:21 2012 +1000 +++ b/win32/src/win32file.i Wed Sep 26 23:11:32 2012 -0400 @@ -25,7 +25,7 @@ #ifndef MS_WINCE //#define FAR #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 +#define _WIN32_WINNT 0x0600 #endif #include "winsock2.h" #include "mswsock.h" @@ -800,7 +800,7 @@ if (!rc) return PyWin_SetAPIError("GetFileInformationByHandle"); // @rdesc The result is a tuple of: - return Py_BuildValue("iNNNiiiiii", + return Py_BuildValue("kNNNkkkkkk", fi.dwFileAttributes, // @tupleitem 0|int|dwFileAttributes| PyWinObject_FromFILETIME(fi.ftCreationTime), // @tupleitem 1|<o PyTime>|ftCreationTime| PyWinObject_FromFILETIME(fi.ftLastAccessTime),// @tupleitem 2|<o PyTime>|ftLastAccessTime| @@ -820,8 +820,6 @@ %} %native(GetFileInformationByHandle) PyGetFileInformationByHandle; - - #ifndef MS_WINCE %{ PyObject *MyGetCompressedFileSize(PyObject *self, PyObject *args) @@ -3001,11 +2999,13 @@ typedef BOOL (WINAPI *Wow64RevertWow64FsRedirectionfunc)(PVOID); static Wow64RevertWow64FsRedirectionfunc pfnWow64RevertWow64FsRedirection = NULL; -/* FILE_INFO_BY_HANDLE_CLASS and various structs used by this function are in fileextd.h, can be downloaded here: -http://www.microsoft.com/downloads/details.aspx?familyid=1decc547-ab00-4963-a360-e4130ec079b8&displaylang=en +/* GetFileInformationByHandleEx and supporting structs are defined in SDK for Vista and later, + but can also be used on XP with a separate header and lib: + http://www.microsoft.com/en-us/download/details.aspx?id=22599 + However, the filextd.lib included is static, so this module would have to be compiled for XP only. +*/ typedef BOOL (WINAPI *GetFileInformationByHandleExfunc)(HANDLE,FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD); static GetFileInformationByHandleExfunc pfnGetFileInformationByHandleEx = NULL; -*/ // From sfc.dll typedef BOOL (WINAPI *SfcGetNextProtectedFilefunc)(HANDLE,PPROTECTED_FILE_DATA); @@ -3988,8 +3988,10 @@ // @object CopyProgressRoutine|Python function used as a callback for <om win32file.CopyFileEx> and <om win32file.MoveFileWithProgress><nl> // Function will receive 9 parameters:<nl> // (TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred, -// StreamNumber, CallbackReason, SourceFile, DestinationFile)<nl> -// SourceFile and DestinationFile are <o PyHANDLE>s, all others are longs.<nl> +// StreamNumber, CallbackReason, SourceFile, DestinationFile, Data)<nl> +// SourceFile and DestinationFile are <o PyHANDLE>s. +// Data is the context object passed to the calling function. +// All others are longs.<nl> // CallbackReason will be one of CALLBACK_CHUNK_FINISHED or CALLBACK_STREAM_SWITCH<nl> // Your implementation of this function must return one of the PROGRESS_* constants. DWORD CALLBACK CopyFileEx_ProgressRoutine( @@ -5448,6 +5450,234 @@ } %} +%{ +// @pyswig object|GetFileInformationByHandleEx|Retrieves extended file information for an open file handle. +// @comm Available on Vista and later. +// @comm Accepts keyword args. +// @rdesc Type of returned object is determined by the requested information class +// @flagh Class|Returned info +// @flag FileBasicInfo|Dict representing a FILE_BASIC_INFO struct +// @flag FileStandardInfo|Dict representing a FILE_STANDARD_INFO struct +// @flag FileNameInfo|String containing the file name, without the drive letter +// @flag FileCompressionInfo|Dict representing a FILE_COMPRESSION_INFO struct +// @flag FileAttributeTagInfo|Dict representing a FILE_ATTRIBUTE_TAG_INFO struct +// @flag FileIdBothDirectoryInfo|Sequence of dicts representing FILE_ID_BOTH_DIR_INFO structs. Call in loop until no more files are returned. +// @flag FileIdBothDirectoryRestartInfo|Sequence of dicts representing FILE_ID_BOTH_DIR_INFO structs. +// @flag FileStreamInfo|Sequence of dicts representing FILE_STREAM_INFO structs +static PyObject *py_GetFileInformationByHandleEx(PyObject *self, PyObject *args, PyObject *kwargs) +{ + // According to MSDN, this function is in kernel32.lib in Vista or later, but I can't get it to link + // with either Vista or Windows 7 sdks. + // On XP, you can use it with the downloadable fileextd.lib add-on, but it's a static library + // and would never call the function exported from kernel32.dll. + CHECK_PFN(GetFileInformationByHandleEx); + static char *keywords[] = {"File", "FileInformationClass", NULL}; + HANDLE handle; + FILE_INFO_BY_HANDLE_CLASS info_class; + void *buf = NULL; + DWORD buflen = 0; + BOOL rc; + DWORD err = 0; + PyObject *ret; + + // @pyparm <o PyHANDLE>|File||Handle to a file or directory. Do not pass a pipe handle. + // @pyparm int|FileInformationClass||Type of data to return, one of win32file.File*Info values + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i", keywords, + PyWinObject_AsHANDLE, &handle, + &info_class)) + return NULL; + + switch (info_class){ + case FileBasicInfo: + buflen = sizeof(FILE_BASIC_INFO); + break; + case FileStandardInfo: + buflen = sizeof(FILE_STANDARD_INFO); + break; + case FileNameInfo: + // FILE_NAME_INFO.FileName is one of those bleeping [1] sized arrays that is treated as variable size. + buflen = sizeof(FILE_NAME_INFO) + (sizeof(WCHAR) * (MAX_PATH + 1)); + // buflen = sizeof(FILE_NAME_INFO) + (10); // Test reallocation logic + break; + case FileCompressionInfo: + buflen = sizeof(FILE_COMPRESSION_INFO); + break; + case FileAttributeTagInfo: + buflen = sizeof(FILE_ATTRIBUTE_TAG_INFO); + break; + // These all return multiple linked structs, allocate extra space. May need to allow for a + // size hint to be passed in if large number of results expected. + case FileIdBothDirectoryInfo: + case FileIdBothDirectoryRestartInfo: + case FileStreamInfo: + buflen = 2048; + break; + default: + PyErr_SetString(PyExc_NotImplementedError, "Unsupported file information class"); + return NULL; + } + + while (true){ + if (buf) + free(buf); + buf = malloc(buflen); + if (buf == NULL){ + PyErr_NoMemory(); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + rc = (*pfnGetFileInformationByHandleEx)(handle, info_class, buf, buflen); + // rc = GetFileInformationByHandleEx(handle, info_class, buf, buflen); + Py_END_ALLOW_THREADS + if (rc) + break; + err = GetLastError(); + // ERROR_MORE_DATA can be returned if: + // FileStreamInfo is called on a file with numerous alternate streams + // FileNameInfo is called on a file whose name exceeds MAX_PATH + if (err == ERROR_MORE_DATA){ + buflen *= 2; + continue; + } + // ERROR_NO_MORE_FILES is returned when using FileIdBothDirectoryInfo and enumeration is done. + // ERROR_HANDLE_EOF is returned when FileStreamInfo is called for a file with no streams + // (should only be for directories). + // Treat either of these as success, and return empty tuple instead of raising an exception + if ((err == ERROR_NO_MORE_FILES && + (info_class == FileIdBothDirectoryInfo || info_class == FileIdBothDirectoryRestartInfo)) + || (err == ERROR_HANDLE_EOF && info_class == FileStreamInfo)) + rc = true; + break; + } + + if (!rc){ + free(buf); + return PyWin_SetAPIError("GetFileInformationByHandleEx", err); + } + switch (info_class){ + case FileBasicInfo:{ + FILE_BASIC_INFO *pbi = (FILE_BASIC_INFO *)buf; + ret = Py_BuildValue("{s:N, s:N, s:N, s:N, s:k}", + "CreationTime", PyWinObject_FromTimeStamp(pbi->CreationTime), + "LastAccessTime", PyWinObject_FromTimeStamp(pbi->LastAccessTime), + "LastWriteTime", PyWinObject_FromTimeStamp(pbi->LastWriteTime), + "ChangeTime", PyWinObject_FromTimeStamp(pbi->ChangeTime), + "FileAttributes", pbi->FileAttributes); + break; + } + case FileStandardInfo:{ + FILE_STANDARD_INFO *psi = (FILE_STANDARD_INFO *)buf; + ret = Py_BuildValue("{s:N, s:N, s:k, s:N, s:N}", + "AllocationSize", PyWinObject_FromLARGE_INTEGER(psi->AllocationSize), + "EndOfFile", PyWinObject_FromLARGE_INTEGER(psi->EndOfFile), + "NumberOfLinks", psi->NumberOfLinks, + "DeletePending", PyBool_FromLong(psi->DeletePending), + "Directory", PyBool_FromLong(psi->Directory)); + break; + } + case FileNameInfo:{ + FILE_NAME_INFO *pni = (FILE_NAME_INFO *)buf; + ret = PyWinObject_FromWCHAR(pni->FileName, pni->FileNameLength/sizeof(WCHAR)); + break; + } + case FileCompressionInfo:{ + FILE_COMPRESSION_INFO *pci = (FILE_COMPRESSION_INFO *)buf; + ret = Py_BuildValue("{s:N, s:H, s:B, s:B, s:B, s:(BBB)}", + "CompressedFileSize", PyWinObject_FromLARGE_INTEGER(pci->CompressedFileSize), + "CompressionFormat", pci->CompressionFormat, + "CompressionUnitShift", pci->CompressionUnitShift, + "ChunkShift", pci->ChunkShift, + "ClusterShift", pci->ClusterShift, + "Reserved", pci->Reserved[0], pci->Reserved[1], pci->Reserved[2]); + break; + } + case FileAttributeTagInfo:{ + FILE_ATTRIBUTE_TAG_INFO *pati = (FILE_ATTRIBUTE_TAG_INFO *)buf; + ret = Py_BuildValue("{s:k, s:k}", + "FileAttributes", pati->FileAttributes, + "ReparseTag", pati->ReparseTag); + break; + } + case FileIdBothDirectoryInfo: + case FileIdBothDirectoryRestartInfo:{ + FILE_ID_BOTH_DIR_INFO *pdi = (FILE_ID_BOTH_DIR_INFO *)buf; + if (err == ERROR_NO_MORE_FILES){ + ret = PyTuple_New(0); + break; + } + ULONG file_cnt = 1; + while (pdi->NextEntryOffset){ + file_cnt++; + pdi = (FILE_ID_BOTH_DIR_INFO *)((BYTE *)pdi + pdi->NextEntryOffset); + }; + ret = PyTuple_New(file_cnt); + if (ret == NULL) + break; + pdi = (FILE_ID_BOTH_DIR_INFO *)buf; + for (ULONG i = 0; i < file_cnt; i++){ + PyObject *file_info = Py_BuildValue("{s:k, s:N, s:N, s:N, s:N, s:N, s:N, s:k, s:k, s:N, s:N, s:N}", + "FileIndex", pdi->FileIndex, + "CreationTime", PyWinObject_FromTimeStamp(pdi->CreationTime), + "LastAccessTime", PyWinObject_FromTimeStamp(pdi->LastAccessTime), + "LastWriteTime", PyWinObject_FromTimeStamp(pdi->LastWriteTime), + "ChangeTime", PyWinObject_FromTimeStamp(pdi->ChangeTime), + "EndOfFile", PyWinObject_FromLARGE_INTEGER(pdi->EndOfFile), + "AllocationSize", PyWinObject_FromLARGE_INTEGER(pdi->AllocationSize), + "FileAttributes", pdi->FileAttributes, + "EaSize", pdi->EaSize, + "ShortName", PyWinObject_FromWCHAR(pdi->ShortName, pdi->ShortNameLength/sizeof(WCHAR)), + "FileId", PyWinObject_FromLARGE_INTEGER(pdi->FileId), + "FileName", PyWinObject_FromWCHAR(pdi->FileName, pdi->FileNameLength/sizeof(WCHAR))); + if (file_info == NULL){ + Py_DECREF(ret); + ret = NULL; + break; + } + PyTuple_SET_ITEM(ret, i, file_info); + pdi = (FILE_ID_BOTH_DIR_INFO *)((BYTE *)pdi + pdi->NextEntryOffset); + } + break; + } + case FileStreamInfo:{ + FILE_STREAM_INFO *psi = (FILE_STREAM_INFO *)buf; + if (err == ERROR_HANDLE_EOF){ + ret = PyTuple_New(0); + break; + } + // Function fails if no streams retrieved, so guaranteed to have at least one struct + DWORD stream_cnt = 1; + while (psi->NextEntryOffset){ + stream_cnt++; + psi = (FILE_STREAM_INFO *)((BYTE *)psi + psi->NextEntryOffset); + }; + ret = PyTuple_New(stream_cnt); + if (ret == NULL) + break; + psi = (FILE_STREAM_INFO *)buf; + for (DWORD i = 0; i < stream_cnt; i++){ + PyObject *stream_info = Py_BuildValue("{s:N, s:N, s:N}", + "StreamSize", PyWinObject_FromLARGE_INTEGER(psi->StreamSize), + "StreamAllocationSize", PyWinObject_FromLARGE_INTEGER(psi->StreamAllocationSize), + "StreamName", PyWinObject_FromWCHAR(psi->StreamName, psi->StreamNameLength/sizeof(WCHAR))); + if (stream_info == NULL){ + Py_DECREF(ret); + ret = NULL; + break; + } + PyTuple_SET_ITEM(ret, i, stream_info); + psi = (FILE_STREAM_INFO *)((BYTE *)psi + psi->NextEntryOffset); + }; + break; + } + default: + PyErr_SetString(PyExc_SystemError, "Mismatched case statements"); + } + free(buf); + return ret; +} +PyCFunction pfnpy_GetFileInformationByHandleEx=(PyCFunction)py_GetFileInformationByHandleEx; +%} + %native (SetVolumeMountPoint) pfnpy_SetVolumeMountPoint; %native (DeleteVolumeMountPoint) pfnpy_DeleteVolumeMountPoint; %native (GetVolumeNameForVolumeMountPoint) pfnpy_GetVolumeNameForVolumeMountPoint; @@ -5483,6 +5713,7 @@ %native (DeleteFileW) pfnpy_DeleteFileW; %native (GetFileAttributesEx) pfnpy_GetFileAttributesEx; %native (GetFileAttributesExW) pfnpy_GetFileAttributesExW; +%native (GetFileInformationByHandleEx) pfnpy_GetFileInformationByHandleEx; |
From: <pyw...@li...> - 2012-09-24 00:21:58
|
changeset 125b96a72be7 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=125b96a72be7 summary: GetPropTagName returns the fully qualified PT_UNICODE/PT_STRING8 type name, GetMapiTypeName tweaks (Nick Czeczulin) diffstat: CHANGES.txt | 4 ++++ com/win32comext/mapi/mapiutil.py | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diffs (73 lines): diff -r 9648d478ad21 -r 125b96a72be7 CHANGES.txt --- a/CHANGES.txt Thu Sep 20 14:15:56 2012 -0400 +++ b/CHANGES.txt Mon Sep 24 10:21:21 2012 +1000 @@ -6,6 +6,10 @@ Since build 217: ---------------- +* mapiutil.py GetPropTagName has been modified to return the fully qualified + PT_UNICODE and PT_STRING8 type name. Added optional argument to override + rawType default in GetMapiTypeName. (Nick Czeczulin) + * Fix the count of replaced terms in Pythonwin's search/replace (rupole). * Fix obscure issues in the Pythonwin code browser and other uses of the diff -r 9648d478ad21 -r 125b96a72be7 com/win32comext/mapi/mapiutil.py --- a/com/win32comext/mapi/mapiutil.py Thu Sep 20 14:15:56 2012 -0400 +++ b/com/win32comext/mapi/mapiutil.py Mon Sep 24 10:21:21 2012 +1000 @@ -16,7 +16,6 @@ # This is so PR_FOO_A and PR_FOO_W are still differentiated, # but should we get a PT_FOO with PT_ERROR set, we fallback # to the ID. - prTable[value] = name # String types should have 3 definitions in mapitags.py # PR_BODY = PROP_TAG( PT_TSTRING, 4096) @@ -25,11 +24,21 @@ # The following change ensures a lookup using only the the # property id returns the conditional default. - if (mapitags.PROP_TYPE(value) == mapitags.PT_UNICODE or \ - mapitags.PROP_TYPE(value) == mapitags.PT_STRING8) and \ - (name[-2:] == '_A' or name[-2:] == '_W'): - continue - prTable[mapitags.PROP_ID(value)] = name + # PT_TSTRING is a conditional assignment for either PT_UNICODE or + # PT_STRING8 and should not be returned during a lookup. + + if mapitags.PROP_TYPE(value) == mapitags.PT_UNICODE or \ + mapitags.PROP_TYPE(value) == mapitags.PT_STRING8: + + if name[-2:] == '_A' or name[-2:] == '_W': + prTable[value] = name + else: + prTable[mapitags.PROP_ID(value)] = name + + else: + prTable[value] = name + prTable[mapitags.PROP_ID(value)] = name + try: try: return prTable[pt] @@ -55,7 +64,7 @@ ptTable = {} -def GetMapiTypeName(propType): +def GetMapiTypeName(propType, rawType=True): """Given a mapi type flag, return a string description of the type""" if not ptTable: for name, value in mapitags.__dict__.iteritems(): @@ -67,8 +76,9 @@ continue ptTable[value] = name - rawType = propType & ~mapitags.MV_FLAG - return ptTable.get(rawType, str(hex(rawType))) + if rawType: + propType = propType & ~mapitags.MV_FLAG + return ptTable.get(propType, str(hex(propType))) def GetProperties(obj, propList): """Given a MAPI object and a list of properties, return a list of property values. |
From: <pyw...@li...> - 2012-09-20 18:39:55
|
changeset c4d977bc3ee9 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=c4d977bc3ee9 summary: Add Get/SetCurrentProcessExplicitAppUserModelID changeset da480ad27dbc in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=da480ad27dbc summary: Autoduck fixes changeset 9648d478ad21 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=9648d478ad21 summary: Correct size of buffer passed to GetCommandString diffstat: com/win32comext/shell/src/PyIContextMenu.cpp | 11 +++-- com/win32comext/shell/src/PyIShellLink.cpp | 48 ++++++++++++----------- com/win32comext/shell/src/shell.cpp | 54 ++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 27 deletions(-) diffs (278 lines): diff -r 977f4f21ae8b -r 9648d478ad21 com/win32comext/shell/src/PyIContextMenu.cpp --- a/com/win32comext/shell/src/PyIContextMenu.cpp Mon Sep 10 17:23:43 2012 -0400 +++ b/com/win32comext/shell/src/PyIContextMenu.cpp Thu Sep 20 14:15:56 2012 -0400 @@ -97,13 +97,16 @@ UINT cchMax = 2048; if ( !PyArg_ParseTuple(args, "OI|I:GetCommandString", &obCmd, &uType, &cchMax) ) return NULL; - if (uType & GCS_UNICODE) - cchMax *= sizeof(WCHAR); // buffer size is in characters + UINT_PTR idCmd; if (!PyWinLong_AsULONG_PTR(obCmd, (ULONG_PTR *)&idCmd)) return NULL; - - char *buf = (char *)malloc(cchMax); + // buffer size is in characters + char *buf; + if (uType & GCS_UNICODE) + buf = (char *)malloc(cchMax * sizeof(WCHAR)); + else + buf = (char *)malloc(cchMax); if (!buf) return PyErr_NoMemory(); HRESULT hr; diff -r 977f4f21ae8b -r 9648d478ad21 com/win32comext/shell/src/PyIShellLink.cpp --- a/com/win32comext/shell/src/PyIShellLink.cpp Mon Sep 10 17:23:43 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellLink.cpp Thu Sep 20 14:15:56 2012 -0400 @@ -27,7 +27,7 @@ return (IShellLink *)PyIUnknown::GetI(self); } -// @pymethod name, <o WIN32_FIND_DATA>|PyIShellLink|GetPath|Retrieves the path and file name of a shell link object +// @pymethod str, <o WIN32_FIND_DATA>|PyIShellLink|GetPath|Retrieves the target path and file name of a shell link object // @comm The AlternateFileName (8.3) member of WIN32_FIND_DATA does not return information PyObject *PyIShellLink::GetPath(PyObject *self, PyObject *args) { @@ -40,7 +40,7 @@ // @flag SLGP_SHORTPATH|Retrieves the standard short (8.3 format) file name. // @flag SLGP_UNCPRIORITY|Retrieves the Universal Naming Convention (UNC) path name of the file. // @flag SLGP_RAWPATH|Retrieves the raw path name. A raw path is something that might not exist and may include environment variables that need to be expanded. - // @pyparm int|cchMaxPath|_MAX_PATH|Description for cchMaxPath + // @pyparm int|cchMaxPath|_MAX_PATH|Number of characters to allocate for returned filename int cchMaxPath = _MAX_PATH; DWORD fFlags; if ( !PyArg_ParseTuple(args, "l|i:GetPath", &fFlags, &cchMaxPath) ) @@ -67,7 +67,7 @@ return ret; } -// @pymethod string|PyIShellLink|GetIDList|Retrieves the list of item identifiers for a shell link object. +// @pymethod <o PyIDL>|PyIShellLink|GetIDList|Retrieves the item id list that identifies the target of the shell link. PyObject *PyIShellLink::GetIDList(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); @@ -86,7 +86,7 @@ return PyObject_FromPIDL(pidl, TRUE); } -// @pymethod |PyIShellLink|SetIDList|Sets the list of item identifiers for a shell link object. +// @pymethod |PyIShellLink|SetIDList|Sets the target of the link using an item id list PyObject *PyIShellLink::SetIDList(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); @@ -94,11 +94,11 @@ return NULL; LPITEMIDLIST pidl; PyObject *obpidl; + // @pyparm <o PyIDL>|pidl||Absolute item id list that identifies the target if ( !PyArg_ParseTuple(args, "O:SetIDList", &obpidl) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyObject_AsPIDL( obpidl, &pidl )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyObject_AsPIDL( obpidl, &pidl )) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISL->SetIDList( pidl ); @@ -112,13 +112,13 @@ return Py_None; } -// @pymethod |PyIShellLink|GetDescription|Description of GetDescription. +// @pymethod str|PyIShellLink|GetDescription|Retrieves the description of the link (displays as Comment in the UI) PyObject *PyIShellLink::GetDescription(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); if ( pISL == NULL ) return NULL; - // @pyparm int|cchMaxName|1024|Description for cchMaxName + // @pyparm int|cchMaxName|1024|Number of character to allocate for the retrieved text int cchMaxName = 1024; if ( !PyArg_ParseTuple(args, "|i:GetDescription", &cchMaxName) ) return NULL; @@ -141,13 +141,14 @@ return ret; } -// @pymethod |PyIShellLink|SetDescription|Description of SetDescription. +// @pymethod |PyIShellLink|SetDescription|Sets the description of the link (displays as Comment in the UI) PyObject *PyIShellLink::SetDescription(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); if ( pISL == NULL ) return NULL; PyObject *obName; + // @pyparm str|Name||The description for the link if ( !PyArg_ParseTuple(args, "O:SetDescription", &obName) ) return NULL; TCHAR *pszName; @@ -165,13 +166,13 @@ return Py_None; } -// @pymethod |PyIShellLink|GetWorkingDirectory|Description of GetWorkingDirectory. +// @pymethod str|PyIShellLink|GetWorkingDirectory|Retrieves the working directory for the link PyObject *PyIShellLink::GetWorkingDirectory(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); if ( pISL == NULL ) return NULL; - // @pyparm int|cchMaxName|1024|Description for cchMaxName + // @pyparm int|cchMaxName|1024|Number of characters to allocate for returned text int cchMaxName = 1024; if ( !PyArg_ParseTuple(args, "|i:GetWorkingDirectory", &cchMaxName) ) return NULL; @@ -194,13 +195,14 @@ return ret; } -// @pymethod |PyIShellLink|SetWorkingDirectory|Description of SetWorkingDirectory. +// @pymethod |PyIShellLink|SetWorkingDirectory|Sets the working directory for the link. PyObject *PyIShellLink::SetWorkingDirectory(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); if ( pISL == NULL ) return NULL; PyObject *obName; + // @pyparm str|Dir||The working directory for the link if ( !PyArg_ParseTuple(args, "O:SetWorkingDirectory", &obName) ) return NULL; TCHAR *pszName; @@ -219,7 +221,7 @@ } -// @pymethod string|PyIShellLink|GetArguments|Retrieves the command-line arguments associated with a shell link object. +// @pymethod str|PyIShellLink|GetArguments|Retrieves the command-line arguments associated with a shell link object. PyObject *PyIShellLink::GetArguments(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); @@ -255,7 +257,7 @@ if ( pISL == NULL ) return NULL; PyObject *obArgs; - // @pyparm string|args||The new arguments. + // @pyparm str|args||The new arguments. if ( !PyArg_ParseTuple(args, "O:SetArguments", &obArgs) ) return NULL; TCHAR *pszArgs; @@ -358,7 +360,7 @@ } -// @pymethod string|PyIShellLink|GetIconLocation|Retrieves the location (path and index) of the icon for a shell link object. +// @pymethod str|PyIShellLink|GetIconLocation|Retrieves the location (path and index) of the icon for a shell link object. PyObject *PyIShellLink::GetIconLocation(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); @@ -516,16 +518,16 @@ return Py_None; } -// @object PyIShellLink|Description of the interface +// @object PyIShellLink|Interface used to access the properties of a shell link file (*.lnk) static struct PyMethodDef PyIShellLink_methods[] = { { "GetPath", PyIShellLink::GetPath, 1 }, // @pymeth GetPath|Retrieves the path and file name of a shell link object. - { "GetIDList", PyIShellLink::GetIDList, 1 }, // @pymeth GetIDList|Retrieves the list of item identifiers for a shell link object. - { "SetIDList", PyIShellLink::SetIDList, 1 }, // @pymeth SetIDList|Sets the list of item identifiers for a shell link object. - { "GetDescription", PyIShellLink::GetDescription, 1 }, // @pymeth GetDescription|Description of GetDescription - { "SetDescription", PyIShellLink::SetDescription, 1 }, // @pymeth SetDescription|Description of SetDescription - { "GetWorkingDirectory", PyIShellLink::GetWorkingDirectory, 1 }, // @pymeth GetWorkingDirectory|Description of GetWorkingDirectory - { "SetWorkingDirectory", PyIShellLink::SetWorkingDirectory, 1 }, // @pymeth SetWorkingDirectory|Description of SetWorkingDirectory + { "GetIDList", PyIShellLink::GetIDList, 1 }, // @pymeth GetIDList|Retrieves the item id list that identifies the target of the shell link. + { "SetIDList", PyIShellLink::SetIDList, 1 }, // @pymeth SetIDList|Sets the target of the link using an item id list + { "GetDescription", PyIShellLink::GetDescription, 1 }, // @pymeth GetDescription|Retrieves the description of the link (displays as Comment in the UI) + { "SetDescription", PyIShellLink::SetDescription, 1 }, // @pymeth SetDescription|Sets the description of the link (displays as Comment in the UI) + { "GetWorkingDirectory", PyIShellLink::GetWorkingDirectory, 1 }, // @pymeth GetWorkingDirectory|Retrieves the working directory for the link + { "SetWorkingDirectory", PyIShellLink::SetWorkingDirectory, 1 }, // @pymeth SetWorkingDirectory|Sets the working directory for the link { "GetArguments", PyIShellLink::GetArguments, 1 }, // @pymeth GetArguments|Retrieves the command-line arguments associated with a shell link object. { "SetArguments", PyIShellLink::SetArguments, 1 }, // @pymeth SetArguments|Sets the command-line arguments associated with a shell link object. { "GetHotkey", PyIShellLink::GetHotkey, 1 }, // @pymeth GetHotkey|Retrieves the hot key for a shell link object. diff -r 977f4f21ae8b -r 9648d478ad21 com/win32comext/shell/src/shell.cpp --- a/com/win32comext/shell/src/shell.cpp Mon Sep 10 17:23:43 2012 -0400 +++ b/com/win32comext/shell/src/shell.cpp Thu Sep 20 14:15:56 2012 -0400 @@ -168,6 +168,12 @@ typedef HRESULT (WINAPI *PFNSHCreateStreamOnFileEx)(LPCWSTR, DWORD, DWORD, BOOL, IStream *, IStream **); static PFNSHCreateStreamOnFileEx pfnSHCreateStreamOnFileEx = NULL; +typedef HRESULT (WINAPI *PFNSetCurrentProcessExplicitAppUserModelID)(WCHAR *); +static PFNSetCurrentProcessExplicitAppUserModelID pfnSetCurrentProcessExplicitAppUserModelID; + +typedef HRESULT (WINAPI *PFNGetCurrentProcessExplicitAppUserModelID)(WCHAR **); +static PFNGetCurrentProcessExplicitAppUserModelID pfnGetCurrentProcessExplicitAppUserModelID; + // Some magic hackery macros :-) #define _ILSkip(pidl, cb) ((LPITEMIDLIST)(((BYTE*)(pidl))+cb)) #define _ILNext(pidl) _ILSkip(pidl, (pidl)->mkid.cb) @@ -3271,6 +3277,50 @@ return PyCom_PyObjectFromIUnknown(ret, IID_IStream, FALSE); } +// @pymethod |shell|SetCurrentProcessExplicitAppUserModelID|Sets the taskbar identifier +static PyObject *PySetCurrentProcessExplicitAppUserModelID(PyObject *self, PyObject *args) +{ + // @comm Should be used early in process startup before creating any windows + // @comm Requires Windows 7 or later + // @pyparm str|AppID||The Application User Model ID used to group taskbar buttons + if (pfnSetCurrentProcessExplicitAppUserModelID==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + TmpWCHAR appid; + PyObject *obappid; + if(!PyArg_ParseTuple(args, "O:SetCurrentProcessExplicitAppUserModelID", &obappid)) + return NULL; + if (!PyWinObject_AsWCHAR(obappid, &appid, FALSE)) + return NULL; + + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSetCurrentProcessExplicitAppUserModelID)(appid); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod str|shell|GetCurrentProcessExplicitAppUserModelID|Retrieves the current taskbar identifier +// @comm Will only retrieve an identifier if set by the application, not a system-assigned default. +// @comm Requires Windows 7 or later +static PyObject *PyGetCurrentProcessExplicitAppUserModelID(PyObject *self, PyObject *args) +{ + if (pfnGetCurrentProcessExplicitAppUserModelID==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + WCHAR* appid; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnGetCurrentProcessExplicitAppUserModelID)(&appid); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + PyObject *ret = PyWinObject_FromWCHAR(appid); + CoTaskMemFree(appid); + return ret; +} + /* List of module functions */ // @module shell|A module wrapping Windows Shell functions and interfaces @@ -3331,6 +3381,8 @@ { "SHCreateShellItem", PySHCreateShellItem, METH_VARARGS}, // @pymeth SHCreateShellItem|Creates an IShellItem interface from a PIDL { "SHOpenFolderAndSelectItems", (PyCFunction)PySHOpenFolderAndSelectItems, METH_VARARGS|METH_KEYWORDS}, // @pymeth SHOpenFolderAndSelectItems|Displays a shell folder with items pre-selected { "SHCreateStreamOnFileEx", (PyCFunction)PySHCreateStreamOnFileEx, METH_VARARGS|METH_KEYWORDS}, // @pymeth SHCreateStreamOnFileEx|Creates a <o PyIStream> that reads and writes to a file + { "SetCurrentProcessExplicitAppUserModelID", PySetCurrentProcessExplicitAppUserModelID, METH_VARARGS}, // @pymeth SetCurrentProcessExplicitAppUserModelID|Sets the taskbar identifier + { "GetCurrentProcessExplicitAppUserModelID", PyGetCurrentProcessExplicitAppUserModelID, METH_NOARGS}, // @pymeth GetCurrentProcessExplicitAppUserModelID|Retrieves the current taskbar identifier { NULL, NULL }, }; @@ -3470,6 +3522,8 @@ pfnSHGetIDListFromObject =(PFNSHGetIDListFromObject)GetProcAddress(shell32, "SHGetIDListFromObject"); pfnSHCreateShellItem =(PFNSHCreateShellItem)GetProcAddress(shell32, "SHCreateShellItem"); pfnSHOpenFolderAndSelectItems = (PFNSHOpenFolderAndSelectItems)GetProcAddress(shell32, "SHOpenFolderAndSelectItems"); + pfnSetCurrentProcessExplicitAppUserModelID = (PFNSetCurrentProcessExplicitAppUserModelID)GetProcAddress(shell32, "SetCurrentProcessExplicitAppUserModelID"); + pfnGetCurrentProcessExplicitAppUserModelID = (PFNGetCurrentProcessExplicitAppUserModelID)GetProcAddress(shell32, "GetCurrentProcessExplicitAppUserModelID"); } // SHGetFolderPath comes from shfolder.dll on older systems if (pfnSHGetFolderPath==NULL){ |
From: <pyw...@li...> - 2012-09-10 21:25:02
|
changeset 977f4f21ae8b in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=977f4f21ae8b summary: Add IKnownFolder and IKnownFolderManager diffstat: com/win32comext/shell/knownfolders.py | 98 ----- com/win32comext/shell/shellcon.py | 40 ++ com/win32comext/shell/src/PyIKnownFolder.cpp | 250 ++++++++++++++ com/win32comext/shell/src/PyIKnownFolder.h | 28 + com/win32comext/shell/src/PyIKnownFolderManager.cpp | 343 ++++++++++++++++++++ com/win32comext/shell/src/PyIKnownFolderManager.h | 29 + com/win32comext/shell/src/shell.cpp | 114 ++++++ setup.py | 2 + 8 files changed, 806 insertions(+), 98 deletions(-) diffs (truncated from 964 to 300 lines): diff -r bec283d926a5 -r 977f4f21ae8b com/win32comext/shell/knownfolders.py --- a/com/win32comext/shell/knownfolders.py Tue Aug 28 01:12:51 2012 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -# from KnownFolders.h -# legacy CSIDL value: CSIDL_NETWORK -# display name: "Network" -# legacy display name: "My Network Places" -# default path: -FOLDERID_NetworkFolder = "{D20BEEC4-5CA8-4905-AE3B-BF251EA09B53}" -FOLDERID_ComputerFolder = "{0AC0837C-BBF8-452A-850D-79D08E667CA7}" -FOLDERID_InternetFolder = "{4D9F7874-4E0C-4904-967B-40B0D20C3E4B}" -FOLDERID_ControlPanelFolder = "{82A74AEB-AEB4-465C-A014-D097EE346D63}" -FOLDERID_PrintersFolder = "{76FC4E2D-D6AD-4519-A663-37BD56068185}" -FOLDERID_SyncManagerFolder = "{43668BF8-C14E-49B2-97C9-747784D784B7}" -FOLDERID_SyncSetupFolder = "{0F214138-B1D3-4a90-BBA9-27CBC0C5389A}" -FOLDERID_ConflictFolder = "{4bfefb45-347d-4006-a5be-ac0cb0567192}" -FOLDERID_SyncResultsFolder = "{289a9a43-be44-4057-a41b-587a76d7e7f9}" -FOLDERID_RecycleBinFolder = "{B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC}" -FOLDERID_ConnectionsFolder = "{6F0CD92B-2E97-45D1-88FF-B0D186B8DEDD}" -FOLDERID_Fonts = "{FD228CB7-AE11-4AE3-864C-16F3910AB8FE}" - -# display name: "Desktop" -# default path: "C:\Users\<UserName>\Desktop" -# legacy default path: "C:\Documents and Settings\<userName>\Desktop" -# legacy CSIDL value: CSIDL_DESKTOP -FOLDERID_Desktop = "{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" -FOLDERID_Startup = "{B97D20BB-F46A-4C97-BA10-5E3608430854}" -FOLDERID_Programs = "{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}" -FOLDERID_StartMenu = "{625B53C3-AB48-4EC1-BA1F-A1EF4146FC19}" -FOLDERID_Recent = "{AE50C081-EBD2-438A-8655-8A092E34987A}" -FOLDERID_SendTo = "{8983036C-27C0-404B-8F08-102D10DCFD74}" -FOLDERID_Documents = "{FDD39AD0-238F-46AF-ADB4-6C85480369C7}" -FOLDERID_Favorites = "{1777F761-68AD-4D8A-87BD-30B759FA33DD}" -FOLDERID_NetHood = "{C5ABBF53-E17F-4121-8900-86626FC2C973}" -FOLDERID_PrintHood = "{9274BD8D-CFD1-41C3-B35E-B13F55A758F4}" -FOLDERID_Templates = "{A63293E8-664E-48DB-A079-DF759E0509F7}" -FOLDERID_CommonStartup = "{82A5EA35-D9CD-47C5-9629-E15D2F714E6E}" -FOLDERID_CommonPrograms = "{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8}" -FOLDERID_CommonStartMenu = "{A4115719-D62E-491D-AA7C-E74B8BE3B067}" -FOLDERID_PublicDesktop = "{C4AA340D-F20F-4863-AFEF-F87EF2E6BA25}" -FOLDERID_ProgramData = "{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}" -FOLDERID_CommonTemplates = "{B94237E7-57AC-4347-9151-B08C6C32D1F7}" -FOLDERID_PublicDocuments = "{ED4824AF-DCE4-45A8-81E2-FC7965083634}" -FOLDERID_RoamingAppData = "{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}" -FOLDERID_LocalAppData = "{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}" -FOLDERID_LocalAppDataLow = "{A520A1A4-1780-4FF6-BD18-167343C5AF16}" -FOLDERID_InternetCache = "{352481E8-33BE-4251-BA85-6007CAEDCF9D}" -FOLDERID_Cookies = "{2B0F765D-C0E9-4171-908E-08A611B84FF6}" -FOLDERID_History = "{D9DC8A3B-B784-432E-A781-5A1130A75963}" -FOLDERID_System = "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}" -FOLDERID_SystemX86 = "{D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27}" -FOLDERID_Windows = "{F38BF404-1D43-42F2-9305-67DE0B28FC23}" -FOLDERID_Profile = "{5E6C858F-0E22-4760-9AFE-EA3317B67173}" -FOLDERID_Pictures = "{33E28130-4E1E-4676-835A-98395C3BC3BB}" -FOLDERID_ProgramFilesX86 = "{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}" -FOLDERID_ProgramFilesCommonX86 = "{DE974D24-D9C6-4D3E-BF91-F4455120B917}" -FOLDERID_ProgramFilesX64 = "{6D809377-6AF0-444b-8957-A3773F02200E}" -FOLDERID_ProgramFilesCommonX64 = "{6365D5A7-0F0D-45e5-87F6-0DA56B6A4F7D}" -FOLDERID_ProgramFiles = "{905e63b6-c1bf-494e-b29c-65b732d3d21a}" -FOLDERID_ProgramFilesCommon = "{F7F1ED05-9F6D-47A2-AAAE-29D317C6F066}" -FOLDERID_AdminTools = "{724EF170-A42D-4FEF-9F26-B60E846FBA4F}" -FOLDERID_CommonAdminTools = "{D0384E7D-BAC3-4797-8F14-CBA229B392B5}" -FOLDERID_Music = "{4BD8D571-6D19-48D3-BE97-422220080E43}" -FOLDERID_Videos = "{18989B1D-99B5-455B-841C-AB7C74E4DDFC}" -FOLDERID_PublicPictures = "{B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5}" -FOLDERID_PublicMusic = "{3214FAB5-9757-4298-BB61-92A9DEAA44FF}" -FOLDERID_PublicVideos = "{2400183A-6185-49FB-A2D8-4A392A602BA3}" -FOLDERID_ResourceDir = "{8AD10C31-2ADB-4296-A8F7-E4701232C972}" -FOLDERID_LocalizedResourcesDir = "{2A00375E-224C-49DE-B8D1-440DF7EF3DDC}" -FOLDERID_CommonOEMLinks = "{C1BAE2D0-10DF-4334-BEDD-7AA20B227A9D}" -FOLDERID_CDBurning = "{9E52AB10-F80D-49DF-ACB8-4330F5687855}" -FOLDERID_UserProfiles = "{0762D272-C50A-4BB0-A382-697DCD729B80}" -FOLDERID_Playlists = "{DE92C1C7-837F-4F69-A3BB-86E631204A23}" -FOLDERID_SamplePlaylists = "{15CA69B3-30EE-49C1-ACE1-6B5EC372AFB5}" -FOLDERID_SampleMusic = "{B250C668-F57D-4EE1-A63C-290EE7D1AA1F}" -FOLDERID_SamplePictures = "{C4900540-2379-4C75-844B-64E6FAF8716B}" -FOLDERID_SampleVideos = "{859EAD94-2E85-48AD-A71A-0969CB56A6CD}" -FOLDERID_PhotoAlbums = "{69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C}" -FOLDERID_Public = "{DFDF76A2-C82A-4D63-906A-5644AC457385}" -FOLDERID_ChangeRemovePrograms = "{df7266ac-9274-4867-8d55-3bd661de872d}" -FOLDERID_AppUpdates = "{a305ce99-f527-492b-8b1a-7e76fa98d6e4}" -FOLDERID_AddNewPrograms = "{de61d971-5ebc-4f02-a3a9-6c82895e5c04}" -FOLDERID_Downloads = "{374DE290-123F-4565-9164-39C4925E467B}" -FOLDERID_PublicDownloads = "{3D644C9B-1FB8-4f30-9B45-F670235F79C0}" -FOLDERID_SavedSearches = "{7d1d3a04-debb-4115-95cf-2f29da2920da}" -FOLDERID_QuickLaunch = "{52a4f021-7b75-48a9-9f6b-4b87a210bc8f}" -FOLDERID_Contacts = "{56784854-C6CB-462b-8169-88E350ACB882}" -FOLDERID_SidebarParts = "{A75D362E-50FC-4fb7-AC2C-A8BEAA314493}" -FOLDERID_SidebarDefaultParts = "{7B396E54-9EC5-4300-BE0A-2482EBAE1A26}" -FOLDERID_TreeProperties = "{5b3749ad-b49f-49c1-83eb-15370fbd4882}" -FOLDERID_PublicGameTasks = "{DEBF2536-E1A8-4c59-B6A2-414586476AEA}" -FOLDERID_GameTasks = "{054FAE61-4DD8-4787-80B6-090220C4B700}" -FOLDERID_SavedGames = "{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}" -FOLDERID_Games = "{CAC52C1A-B53D-4edc-92D7-6B2E8AC19434}" -FOLDERID_RecordedTV = "{bd85e001-112e-431e-983b-7b15ac09fff1}" -FOLDERID_SEARCH_MAPI = "{98ec0e18-2098-4d44-8644-66979315a281}" -FOLDERID_SEARCH_CSC = "{ee32e446-31ca-4aba-814f-a5ebd2fd6d5e}" -FOLDERID_Links = "{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}" -FOLDERID_UsersFiles = "{f3ce0f7c-4901-4acc-8648-d5d44b04ef8f}" -FOLDERID_SearchHome = "{190337d1-b8ca-4121-a639-6d472d16972a}" -FOLDERID_OriginalImages = "{2C36C0AA-5812-4b87-BFD0-4CD0DFB19B39}" diff -r bec283d926a5 -r 977f4f21ae8b com/win32comext/shell/shellcon.py --- a/com/win32comext/shell/shellcon.py Tue Aug 28 01:12:51 2012 -0400 +++ b/com/win32comext/shell/shellcon.py Mon Sep 10 17:23:43 2012 -0400 @@ -1286,3 +1286,43 @@ ## STR_PROPERTYBAG_PARAM STR_SKIP_BINDING_CLSID = "Skip Binding CLSID" STR_TRACK_CLSID = "Track the CLSID" + +## KF_REDIRECTION_CAPABILITIES enum +KF_REDIRECTION_CAPABILITIES_ALLOW_ALL = 0x000000FF +KF_REDIRECTION_CAPABILITIES_REDIRECTABLE = 0x00000001 +KF_REDIRECTION_CAPABILITIES_DENY_ALL = 0x000FFF00 +KF_REDIRECTION_CAPABILITIES_DENY_POLICY_REDIRECTED = 0x00000100 +KF_REDIRECTION_CAPABILITIES_DENY_POLICY = 0x00000200 +KF_REDIRECTION_CAPABILITIES_DENY_PERMISSIONS = 0x00000400 + +## KF_REDIRECT_FLAGS enum +KF_REDIRECT_USER_EXCLUSIVE = 0x00000001 +KF_REDIRECT_COPY_SOURCE_DACL = 0x00000002 +KF_REDIRECT_OWNER_USER = 0x00000004 +KF_REDIRECT_SET_OWNER_EXPLICIT = 0x00000008 +KF_REDIRECT_CHECK_ONLY = 0x00000010 +KF_REDIRECT_WITH_UI = 0x00000020 +KF_REDIRECT_UNPIN = 0x00000040 +KF_REDIRECT_PIN = 0x00000080 +KF_REDIRECT_COPY_CONTENTS = 0x00000200 +KF_REDIRECT_DEL_SOURCE_CONTENTS = 0x00000400 +KF_REDIRECT_EXCLUDE_ALL_KNOWN_SUBFOLDERS = 0x00000800 + +## KF_CATEGORY enum +KF_CATEGORY_VIRTUAL = 0x00000001 +KF_CATEGORY_FIXED = 0x00000002 +KF_CATEGORY_COMMON = 0x00000003 +KF_CATEGORY_PERUSER = 0x00000004 + +## FFFP_MODE enum +FFFP_EXACTMATCH = 0 +FFFP_NEARESTPARENTMATCH = 1 + +KF_FLAG_CREATE = 0x00008000 +KF_FLAG_DONT_VERIFY = 0x00004000 +KF_FLAG_DONT_UNEXPAND = 0x00002000 +KF_FLAG_NO_ALIAS = 0x00001000 +KF_FLAG_INIT = 0x00000800 +KF_FLAG_DEFAULT_PATH = 0x00000400 +KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200 +KF_FLAG_SIMPLE_IDLIST = 0x00000100 diff -r bec283d926a5 -r 977f4f21ae8b com/win32comext/shell/src/PyIKnownFolder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/com/win32comext/shell/src/PyIKnownFolder.cpp Mon Sep 10 17:23:43 2012 -0400 @@ -0,0 +1,250 @@ +// This file implements the IKnownFolder Interface for Python. +// Generated by makegw.py + +#include "shell_pch.h" +#include "PyIKnownFolder.h" + +// @doc - This file contains autoduck documentation +// --------------------------------------------------- +// +// Interface Implementation + +PyIKnownFolder::PyIKnownFolder(IUnknown *pdisp): + PyIUnknown(pdisp) +{ + ob_type = &type; +} + +PyIKnownFolder::~PyIKnownFolder() +{ +} + +/* static */ IKnownFolder *PyIKnownFolder::GetI(PyObject *self) +{ + return (IKnownFolder *)PyIUnknown::GetI(self); +} + +// @pymethod <o PyIID>|PyIKnownFolder|GetId|Returns the id of the folder +PyObject *PyIKnownFolder::GetId(PyObject *self, PyObject *args) +{ + IKnownFolder *pIKF = GetI(self); + if ( pIKF == NULL ) + return NULL; + KNOWNFOLDERID kfid; + if ( !PyArg_ParseTuple(args, ":GetId")) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIKF->GetId( &kfid ); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIKF, IID_IKnownFolder ); + return PyWinObject_FromIID(kfid); +} + +// @pymethod int|PyIKnownFolder|GetCategory|Returns the category for a folder (shellcon.KF_CATEGORY_*) +PyObject *PyIKnownFolder::GetCategory(PyObject *self, PyObject *args) +{ + IKnownFolder *pIKF = GetI(self); + if ( pIKF == NULL ) + return NULL; + KF_CATEGORY category; + if ( !PyArg_ParseTuple(args, ":GetCategory")) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIKF->GetCategory(&category ); + PY_INTERFACE_POSTCALL; + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIKF, IID_IKnownFolder ); + return PyInt_FromLong(category); +} + +// @pymethod <o PyIShellItem>|PyIKnownFolder|GetShellItem|Returns a shell interface for the folder +PyObject *PyIKnownFolder::GetShellItem(PyObject *self, PyObject *args) +{ + IKnownFolder *pIKF = GetI(self); + if ( pIKF == NULL ) + return NULL; + // @pyparm int|Flags|0|Combination of shellcon.KF_FLAG_* values + // @pyparm <o PyIID>|riid|IID_IShellItem|The interface to return (IShellItem or IShellItem2) + DWORD flags = 0; + IID riid = IID_IShellItem; + void *ret; + if ( !PyArg_ParseTuple(args, "|kO&:GetShellItem", &flags, PyWinObject_AsIID, &riid)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIKF->GetShellItem(flags, riid, &ret); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIKF, IID_IKnownFolder ); + return PyCom_PyObjectFromIUnknown((IUnknown *)ret, riid, FALSE); +} + +// @pymethod str|PyIKnownFolder|GetPath|Returns the path to the folder +PyObject *PyIKnownFolder::GetPath(PyObject *self, PyObject *args) +{ + IKnownFolder *pIKF = GetI(self); + if ( pIKF == NULL ) + return NULL; + // @pyparm int|Flags|0|Combination of shellcon.KF_FLAG_* flags controlling how the path is returned + DWORD flags=0; + WCHAR *path; + if ( !PyArg_ParseTuple(args, "|k:GetPath", &flags)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIKF->GetPath(flags, &path); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIKF, IID_IKnownFolder ); + PyObject *ret = PyWinObject_FromWCHAR(path); + CoTaskMemFree(path); + return ret; +} + +// @pymethod |PyIKnownFolder|SetPath|Changes the location of the folder +PyObject *PyIKnownFolder::SetPath(PyObject *self, PyObject *args) +{ + IKnownFolder *pIKF = GetI(self); + if ( pIKF == NULL ) + return NULL; + // @pyparm int|Flags||KF_FLAG_DONT_UNEXPAND, or 0 + // @pyparm str|Path||New path for known folder + TmpWCHAR Path; + PyObject *obPath; + DWORD Flags; + if ( !PyArg_ParseTuple(args, "kO:SetPath", &Flags, &obPath)) + return NULL; + if (!PyWinObject_AsWCHAR(obPath, &Path)) + return NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIKF->SetPath(Flags, Path); + PY_INTERFACE_POSTCALL; + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr, pIKF, IID_IKnownFolder ); + Py_INCREF(Py_None); + return Py_None; +} + +// @pymethod <o PyIDL>|PyIKnownFolder|GetIDList|Returns the folder's location as an item id list. +PyObject *PyIKnownFolder::GetIDList(PyObject *self, PyObject *args) +{ + IKnownFolder *pIKF = GetI(self); + if ( pIKF == NULL ) + return NULL; + // @pyparm int|Flags||Combination of shellcon.KF_FLAG_* values that affect how the operation is performed + PIDLIST_ABSOLUTE pidl; + DWORD Flags; + if ( !PyArg_ParseTuple(args, "k:GetIDList", &Flags)) + return NULL; + HRESULT hr; |
From: <pyw...@li...> - 2012-08-28 05:14:05
|
changeset bec283d926a5 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=bec283d926a5 summary: Allow variant currency conversions (VT_CY) to work with _decimal module in Python 3.3 diffstat: com/win32com/src/PyComHelpers.cpp | 63 +++++++++++++++++++++++++++----------- 1 files changed, 44 insertions(+), 19 deletions(-) diffs (90 lines): diff -r e2e6637fbaa1 -r bec283d926a5 com/win32com/src/PyComHelpers.cpp --- a/com/win32com/src/PyComHelpers.cpp Sat Aug 25 14:59:12 2012 -0400 +++ b/com/win32com/src/PyComHelpers.cpp Tue Aug 28 01:12:51 2012 -0400 @@ -41,6 +41,31 @@ } // Currency conversions. +// Should probably place this in module dict so it can be DECREF'ed on finalization +// Also may get borked by a reload of the decimal module +static PyObject *Decimal_class = NULL; + +PyObject *get_Decimal_class(void) +{ + // Try to import compiled _decimal module introduced in Python 3.3 + TmpPyObject decimal_module = PyImport_ImportModule("_decimal"); + + // Look for python implemented module introduced in Python 2.4 + if (decimal_module==NULL){ + PyErr_Clear(); + decimal_module = PyImport_ImportModule("decimal"); + } + + // Look for our own copy included in Pywin32 for Python 2.3 + if (decimal_module==NULL){ + PyErr_Clear(); + decimal_module=PyImport_ImportModule("win32com.decimal_23"); + } + if (decimal_module==NULL) + return NULL; + return PyObject_GetAttrString(decimal_module, "Decimal"); +} + PyObject *PyObject_FromCurrency(CURRENCY &cy) { #if (PY_VERSION_HEX < 0x03000000) @@ -48,35 +73,35 @@ #else static char *divname = "__truediv__"; #endif - static PyObject *decimal_module=NULL; - PyObject *result = NULL; - - if (decimal_module==NULL){ - decimal_module=PyImport_ImportModule("decimal"); - if (!decimal_module) { - PyErr_Clear(); - decimal_module=PyImport_ImportModule("win32com.decimal_23"); - } + if (Decimal_class == NULL){ + Decimal_class = get_Decimal_class(); + if (Decimal_class == NULL) + return NULL; } - if (decimal_module==NULL) + + TmpPyObject unscaled_result = PyObject_CallFunction(Decimal_class, "L", cy.int64); + if (unscaled_result == NULL) return NULL; - - PyObject *unscaled_result; - unscaled_result=PyObject_CallMethod(decimal_module, "Decimal", "L", cy.int64); - if (unscaled_result!=NULL){ - result=PyObject_CallMethod(unscaled_result, divname, "l", 10000); - Py_DECREF(unscaled_result); - } - return result; + return PyObject_CallMethod(unscaled_result, divname, "l", 10000); } PYCOM_EXPORT BOOL PyObject_AsCurrency(PyObject *ob, CURRENCY *pcy) { - if (strcmp(ob->ob_type->tp_name, "Decimal")!=0){ + if (Decimal_class == NULL){ + Decimal_class = get_Decimal_class(); + if (Decimal_class == NULL) + return FALSE; + } + + int right_type = PyObject_IsInstance(ob, Decimal_class); + if (right_type == -1) + return FALSE; + else if (right_type == 0){ PyErr_Format(PyExc_TypeError, "Currency object must be a Decimal instance (got %s).",ob->ob_type->tp_name); return FALSE; } + TmpPyObject scaled = PyObject_CallMethod(ob, "__mul__", "l", 10000); if (scaled == NULL) return FALSE; |
From: <pyw...@li...> - 2012-08-28 02:53:55
|
changeset e2e6637fbaa1 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=e2e6637fbaa1 summary: Make sure any return codes from python handler functions are passed back to service framework diffstat: win32/Lib/win32serviceutil.py | 16 ++++++++-------- win32/src/PythonService.cpp | 12 +++++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diffs (62 lines): diff -r b152e0e96498 -r e2e6637fbaa1 win32/Lib/win32serviceutil.py --- a/win32/Lib/win32serviceutil.py Sat Aug 25 00:53:24 2012 -0400 +++ b/win32/Lib/win32serviceutil.py Sat Aug 25 14:59:12 2012 -0400 @@ -808,27 +808,27 @@ pass def ServiceCtrlHandler(self, control): - self.ServiceCtrlHandlerEx(control, 0, None) + return self.ServiceCtrlHandlerEx(control, 0, None) # The 'Ex' functions, which take additional params def SvcOtherEx(self, control, event_type, data): # The default here is to call self.SvcOther as that is the old behaviour. # If you want to take advantage of the extra data, override this method - self.SvcOther(control) + return self.SvcOther(control) def ServiceCtrlHandlerEx(self, control, event_type, data): if control==win32service.SERVICE_CONTROL_STOP: - self.SvcStop() + return self.SvcStop() elif control==win32service.SERVICE_CONTROL_PAUSE: - self.SvcPause() + return self.SvcPause() elif control==win32service.SERVICE_CONTROL_CONTINUE: - self.SvcContinue() + return self.SvcContinue() elif control==win32service.SERVICE_CONTROL_INTERROGATE: - self.SvcInterrogate() + return self.SvcInterrogate() elif control==win32service.SERVICE_CONTROL_SHUTDOWN: - self.SvcShutdown() + return self.SvcShutdown() else: - self.SvcOtherEx(control, event_type, data) + return self.SvcOtherEx(control, event_type, data) def SvcRun(self): self.ReportServiceStatus(win32service.SERVICE_RUNNING) diff -r b152e0e96498 -r e2e6637fbaa1 win32/src/PythonService.cpp --- a/win32/src/PythonService.cpp Sat Aug 25 00:53:24 2012 -0400 +++ b/win32/src/PythonService.cpp Sat Aug 25 14:59:12 2012 -0400 @@ -988,10 +988,16 @@ if (result==NULL) { ReportPythonError(PYS_E_SERVICE_CONTROL_FAILED); dwResult = ERROR_CALL_NOT_IMPLEMENTED; // correct code? - } else if (PyInt_Check(result)||PyLong_Check(result)) - dwResult = PyInt_AsLong(result); - else + } + else if (result == Py_None) dwResult = NOERROR; + else{ + dwResult = PyInt_AsUnsignedLongMask(result); + if (dwResult == -1 && PyErr_Occurred()){ + ReportPythonError(PYS_E_SERVICE_CONTROL_FAILED); + dwResult = ERROR_SERVICE_SPECIFIC_ERROR; + } + } Py_XDECREF(result); return dwResult; |
From: <pyw...@li...> - 2012-08-25 04:54:09
|
changeset b152e0e96498 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=b152e0e96498 summary: Remove 2-int conversion for currency variants diffstat: com/win32com/src/PyComHelpers.cpp | 37 +++++++++++++------------------------ 1 files changed, 13 insertions(+), 24 deletions(-) diffs (48 lines): diff -r 196b2bf6a4ce -r b152e0e96498 com/win32com/src/PyComHelpers.cpp --- a/com/win32com/src/PyComHelpers.cpp Fri Aug 24 13:09:08 2012 -0400 +++ b/com/win32com/src/PyComHelpers.cpp Sat Aug 25 00:53:24 2012 -0400 @@ -72,31 +72,20 @@ PYCOM_EXPORT BOOL PyObject_AsCurrency(PyObject *ob, CURRENCY *pcy) { - if (!PyTuple_Check(ob) || PyTuple_Size(ob) != 2 || - !PyLong_Check(PyTuple_GET_ITEM(ob, 0)) || - !PyLong_Check(PyTuple_GET_ITEM(ob, 1))) - { - if (strcmp(ob->ob_type->tp_name, "Decimal")==0) { - PyObject *scaled = PyObject_CallMethod(ob, "__mul__", "l", 10000); - if (!scaled) return FALSE; - PyObject *longval = PyNumber_Long(scaled); - Py_DECREF(scaled); - pcy->int64 = PyLong_AsLongLong(longval); - Py_DECREF(longval); - if (pcy->int64 == -1 && PyErr_Occurred()) - return FALSE; - } else { - PyErr_Format( - PyExc_TypeError, - "Currency object must be either a tuple of 2 longs or a " - "Decimal instance (got %s).", - ob->ob_type->tp_name); - return FALSE; + if (strcmp(ob->ob_type->tp_name, "Decimal")!=0){ + PyErr_Format(PyExc_TypeError, + "Currency object must be a Decimal instance (got %s).",ob->ob_type->tp_name); + return FALSE; } - } else { - pcy->Hi = PyLong_AsLong(PyTuple_GET_ITEM(ob, 0)); - pcy->Lo = PyLong_AsLong(PyTuple_GET_ITEM(ob, 1)); - } + TmpPyObject scaled = PyObject_CallMethod(ob, "__mul__", "l", 10000); + if (scaled == NULL) + return FALSE; + TmpPyObject longval = PyNumber_Long(scaled); + if (longval == NULL) + return FALSE; + pcy->int64 = PyLong_AsLongLong(longval); + if (pcy->int64 == -1 && PyErr_Occurred()) + return FALSE; return TRUE; } |
From: <pyw...@li...> - 2012-08-24 17:12:52
|
changeset 196b2bf6a4ce in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=196b2bf6a4ce summary: Allow NSI_DWORD members of set structs to accept python longs diffstat: win32/src/win32net/win32netmodule.cpp | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-) diffs (59 lines): diff -r e7d21102da8d -r 196b2bf6a4ce win32/src/win32net/win32netmodule.cpp --- a/win32/src/win32net/win32netmodule.cpp Fri Aug 24 10:50:19 2012 -0400 +++ b/win32/src/win32net/win32netmodule.cpp Fri Aug 24 13:09:08 2012 -0400 @@ -121,28 +121,32 @@ *((WCHAR **)(buf+pItem->off)) = wsz; break; case NSI_DWORD: - if (!PyInt_Check(subob)) { + *((DWORD *)(buf+pItem->off)) = PyInt_AsUnsignedLongMask(subob); + if (*((DWORD *)(buf+pItem->off)) == -1 && PyErr_Occurred()){ + PyErr_Clear(); + PyErr_Format(PyExc_TypeError, "The mapping attribute '%s' must be an unsigned 32 bit int", pItem->attrname); + Py_DECREF(subob); + goto done; + } + break; + case NSI_LONG: + *((LONG *)(buf+pItem->off)) = PyInt_AsLong(subob); + if (*((LONG *)(buf+pItem->off)) == -1 && PyErr_Occurred()){ + PyErr_Clear(); PyErr_Format(PyExc_TypeError, "The mapping attribute '%s' must be an integer", pItem->attrname); Py_DECREF(subob); goto done; } - *((DWORD *)(buf+pItem->off)) = (DWORD)PyInt_AsLong(subob); break; - case NSI_LONG: - if (!PyInt_Check(subob)) { - PyErr_Format(PyExc_TypeError, "The mapping attribute '%s' must be an integer", pItem->attrname); + case NSI_BOOL: + *((BOOL *)(buf+pItem->off)) = PyObject_IsTrue(subob); + if (*((BOOL *)(buf+pItem->off)) == -1 && PyErr_Occurred()){ + PyErr_Clear(); + PyErr_Format(PyExc_TypeError, "The mapping attribute '%s' must be boolean", pItem->attrname); Py_DECREF(subob); goto done; } - *((LONG *)(buf+pItem->off)) = (LONG)PyInt_AsLong(subob); - break; - case NSI_BOOL: - if (!PyInt_Check(subob)) { - PyErr_Format(PyExc_TypeError, "The mapping attribute '%s' must be an integer", pItem->attrname); - Py_DECREF(subob); - goto done; - } - *((BOOL *)(buf+pItem->off)) = (BOOL)PyInt_AsLong(subob); + break; case NSI_HOURS: if (subob != Py_None) { @@ -213,7 +217,7 @@ newObj = PyWinObject_FromWCHAR(*((WCHAR **)(buf+pItem->off))); break; case NSI_DWORD: - newObj = PyInt_FromLong(*((DWORD *)(buf+pItem->off))); + newObj = PyLong_FromUnsignedLong(*((DWORD *)(buf+pItem->off))); break; case NSI_LONG: newObj = PyInt_FromLong(*((LONG *)(buf+pItem->off))); |
From: <pyw...@li...> - 2012-08-24 14:51:50
|
changeset e7d21102da8d in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=e7d21102da8d summary: When calling PyObject_FromSTRRET, make sure pidls are freed *after* they're used diffstat: com/win32comext/shell/src/PyIShellFolder.cpp | 6 ++-- com/win32comext/shell/src/PyIShellFolder2.cpp | 5 ++- com/win32comext/shell/src/shell.cpp | 37 ++++++-------------------- com/win32comext/shell/src/shell_pch.h | 1 - 4 files changed, 15 insertions(+), 34 deletions(-) diffs (139 lines): diff -r e647878b4ccc -r e7d21102da8d com/win32comext/shell/src/PyIShellFolder.cpp --- a/com/win32comext/shell/src/PyIShellFolder.cpp Thu Aug 23 18:07:43 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellFolder.cpp Fri Aug 24 10:50:19 2012 -0400 @@ -365,13 +365,13 @@ STRRET out; PY_INTERFACE_PRECALL; hr = pISF->GetDisplayNameOf( pidl, uFlags, &out ); - PyObject_FreePIDL(pidl); - PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISF, IID_IShellFolder ); - return PyObject_FromSTRRET(&out, pidl, TRUE); + PyObject *ret = PyObject_FromSTRRET(&out, pidl, TRUE); + PyObject_FreePIDL(pidl); + return ret; } // @pymethod <o PyIDL>|PyIShellFolder|SetNameOf|Sets the display name of an item and changes its PIDL diff -r e647878b4ccc -r e7d21102da8d com/win32comext/shell/src/PyIShellFolder2.cpp --- a/com/win32comext/shell/src/PyIShellFolder2.cpp Thu Aug 23 18:07:43 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellFolder2.cpp Fri Aug 24 10:50:19 2012 -0400 @@ -157,11 +157,12 @@ HRESULT hr; PY_INTERFACE_PRECALL; hr = pISF2->GetDetailsOf( pidl, iColumn, &sd ); - PyObject_FreePIDL(pidl); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISF2, IID_IShellFolder2 ); - return Py_BuildValue("(iiN)", sd.fmt, sd.cxChar, PyObject_FromSTRRET(&sd.str, pidl, TRUE)); + PyObject *ret = Py_BuildValue("(iiN)", sd.fmt, sd.cxChar, PyObject_FromSTRRET(&sd.str, pidl, TRUE)); + PyObject_FreePIDL(pidl); + return ret; } // @pymethod <o SHCOLUMNID>|PyIShellFolder2|MapColumnToSCID|Returns the unique identifier (FMTID, pid) of a column diff -r e647878b4ccc -r e7d21102da8d com/win32comext/shell/src/shell.cpp --- a/com/win32comext/shell/src/shell.cpp Thu Aug 23 18:07:43 2012 -0400 +++ b/com/win32comext/shell/src/shell.cpp Fri Aug 24 10:50:19 2012 -0400 @@ -611,22 +611,6 @@ pci->nShow, pci->dwHotKey, PyWinLong_FromHANDLE(pci->hIcon)); } -BOOL PyObject_AsSTRRET( PyObject *ob, STRRET &out ) -{ - if (PyInt_Check(ob)) { - out.uType = STRRET_OFFSET; - out.uOffset = PyInt_AsLong(ob); - return TRUE; - } - if (PyString_Check(ob)) { - out.uType = STRRET_CSTR; - strncpy(out.cStr, PyString_AsString(ob), MAX_PATH); - return TRUE; - } - PyErr_Format(PyExc_TypeError, "Can't convert objects of type '%s' to STRRET", ob->ob_type->tp_name); - return FALSE; -} - void PyObject_FreeSTRRET(STRRET &s) { if (s.uType==STRRET_WSTR) { @@ -638,8 +622,6 @@ PyObject *PyObject_FromSTRRET(STRRET *ps, ITEMIDLIST *pidl, BOOL bFree) { if (ps==NULL) { - if (bFree) - PyObject_FreeSTRRET(*ps); Py_INCREF(Py_None); return Py_None; } @@ -2682,31 +2664,30 @@ PyObject *ret = NULL; PyObject *obpidl; SIGDN flags; - WCHAR *strret = NULL; + WCHAR *name = NULL; PIDLIST_ABSOLUTE pidl = NULL; if(!PyArg_ParseTuple(args, "Ok:SHGetNameFromIDList", &obpidl, &flags)) return NULL; - // @pyparm PIDL|parent|| - // @pyparm int|flags|| + // @pyparm <o PyIDL>|pidl||Absolute ID list of the item + // @pyparm int|flags||Type of name to return, shellcon.SIGDN_* if (!PyObject_AsPIDL(obpidl, &pidl)) goto done; HRESULT hr; { PY_INTERFACE_PRECALL; - hr = (*pfnSHGetNameFromIDList)(pidl, flags, &strret); + hr = (*pfnSHGetNameFromIDList)(pidl, flags, &name); PY_INTERFACE_POSTCALL; } if (FAILED(hr)) { PyCom_BuildPyException(hr); goto done; } - // ref on view consumed by ret object. - ret = PyWinObject_FromWCHAR(strret); + ret = PyWinObject_FromWCHAR(name); done: if (pidl) PyObject_FreePIDL(pidl); - if (strret) - CoTaskMemFree(strret); + if (name) + CoTaskMemFree(name); return ret; } @@ -2729,13 +2710,13 @@ IShellItemArray *sia_ret = NULL; if(!PyArg_ParseTuple(args, "OOO:SHCreateShellItemArray", &obParent, &obsf, &obChildren)) return NULL; - // @pyparm PIDL|parent|| + // @pyparm <o PyIDL>|parent||Absolute ID list of parent folder, or None if sf is specified if (!PyObject_AsPIDL(obParent, &parent, TRUE)) goto done; // @pyparm <o PyIShellFolder>|sf||The Shell data source object that is the parent of the child items specified in children. If parent is specified, this parameter can be NULL. if (!PyCom_InterfaceFromPyInstanceOrObject(obsf, IID_IShellFolder, (void **)&sf, TRUE/* bNoneOK */)) goto done; - // @pyparm [PIDL, ...]|children|| + // @pyparm [<o PyIDL>, ...]|children||Sequence of relative IDLs for items in the parent folder if (!PyObject_AsPIDLArray(obChildren, &nchildren, &children)) goto done; HRESULT hr; diff -r e647878b4ccc -r e7d21102da8d com/win32comext/shell/src/shell_pch.h --- a/com/win32comext/shell/src/shell_pch.h Thu Aug 23 18:07:43 2012 -0400 +++ b/com/win32comext/shell/src/shell_pch.h Fri Aug 24 10:50:19 2012 -0400 @@ -20,7 +20,6 @@ void PyObject_FreeCMINVOKECOMMANDINFO( CMINVOKECOMMANDINFO *pci ); PyObject *PyObject_FromCMINVOKECOMMANDINFO(const CMINVOKECOMMANDINFO *pci); -BOOL PyObject_AsSTRRET( PyObject *obout, STRRET &out ); void PyObject_FreeSTRRET(STRRET &); PyObject *PyObject_FromSTRRET(STRRET *pci, ITEMIDLIST *pidl, BOOL bFree); |
From: <pyw...@li...> - 2012-08-23 22:09:52
|
changeset e647878b4ccc in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=e647878b4ccc summary: Don't throw an error when CListCtrl::GetItemText returns an empty string, as it can do so legitimately diffstat: Pythonwin/win32ctrlList.cpp | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diffs (27 lines): diff -r 4f51918ce379 -r e647878b4ccc Pythonwin/win32ctrlList.cpp --- a/Pythonwin/win32ctrlList.cpp Wed Aug 22 22:57:09 2012 -0400 +++ b/Pythonwin/win32ctrlList.cpp Thu Aug 23 18:07:43 2012 -0400 @@ -486,7 +486,7 @@ PyObject *PyCListCtrl_GetItemText( PyObject *self, PyObject *args ) { int item, sub; - TCHAR buf[256]; + // TCHAR buf[256]; if (!PyArg_ParseTuple( args, "ii:GetItemText", &item, // @pyparm int|item||The index of the item whose text is to be retrieved. &sub)) // @pyparm int|sub||Specifies the subitem whose text is to be retrieved. @@ -494,11 +494,10 @@ CListCtrl *pList = GetListCtrl(self); if (!pList) return NULL; GUI_BGN_SAVE; - int len = pList->GetItemText(item, sub, buf, sizeof(buf)/sizeof(TCHAR)); + // int len = pList->GetItemText(item, sub, buf, sizeof(buf)/sizeof(TCHAR)); + CString s = pList->GetItemText(item, sub); GUI_END_SAVE; - if (len==0) - RETURN_ERR("GetItemText failed"); - return PyWinObject_FromTCHAR(buf,len); + return PyWinObject_FromTCHAR(s); } // @pymethod int|PyCListCtrl|SetItemText|Changes the text of a list view item or subitem. |
From: <pyw...@li...> - 2012-08-23 02:58:25
|
changeset 4f51918ce379 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=4f51918ce379 summary: Convert PROPVARIANT values outside the range of a long to VT_I8 or VT_UI8 diffstat: com/win32com/src/extensions/PyIPropertyStorage.cpp | 26 ++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diffs (39 lines): diff -r acf52e97b876 -r 4f51918ce379 com/win32com/src/extensions/PyIPropertyStorage.cpp --- a/com/win32com/src/extensions/PyIPropertyStorage.cpp Wed Aug 22 07:35:18 2012 -0400 +++ b/com/win32com/src/extensions/PyIPropertyStorage.cpp Wed Aug 22 22:57:09 2012 -0400 @@ -322,9 +322,35 @@ } else if (ob==Py_False) { pVar->boolVal = 0; pVar->vt = VT_BOOL; + } else if (PyLong_Check(ob)) { + pVar->hVal.QuadPart = PyLong_AsLongLong(ob); + if (pVar->hVal.QuadPart == -1 && PyErr_Occurred()){ + // Could still fit in an unsigned long long + PyErr_Clear(); + pVar->uhVal.QuadPart = PyLong_AsUnsignedLongLong(ob); + if (pVar->uhVal.QuadPart == -1 && PyErr_Occurred()) + return FALSE; + pVar->vt = VT_UI8; + } + else{ + pVar->vt=VT_I8; + // Could still fit in a regular long + if (pVar->hVal.QuadPart >= LONG_MIN && pVar->hVal.QuadPart <= LONG_MAX){ + pVar->lVal = (long)pVar->hVal.QuadPart; + pVar->vt = VT_I4; + } + // ... or an unsigned long + else if (pVar->hVal.QuadPart >=0 && pVar->hVal.QuadPart <= ULONG_MAX){ + pVar->ulVal = (unsigned long)pVar->hVal.QuadPart; + pVar->vt = VT_UI4; + } + } +#if (PY_VERSION_HEX < 0x03000000) + // Not needed in Py3k, as PyInt_Check is defined to PyLong_Check } else if (PyInt_Check(ob)) { pVar->lVal = PyInt_AsLong(ob); pVar->vt = VT_I4; +#endif } else if (PyFloat_Check(ob)) { pVar->dblVal = PyFloat_AsDouble(ob); pVar->vt = VT_R8; |
From: <pyw...@li...> - 2012-08-22 11:36:26
|
changeset acf52e97b876 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=acf52e97b876 summary: Don't leave an exception hanging if EnumWindows callback fails diffstat: win32/src/win32gui.i | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diffs (50 lines): diff -r cb8d7cb7982e -r acf52e97b876 win32/src/win32gui.i --- a/win32/src/win32gui.i Tue Aug 21 21:32:33 2012 -0400 +++ b/win32/src/win32gui.i Wed Aug 22 07:35:18 2012 -0400 @@ -2066,20 +2066,27 @@ PyEnumWindowsCallback *cb = (PyEnumWindowsCallback *)lParam; CEnterLeavePython _celp; PyObject *args = Py_BuildValue("(NO)", PyWinLong_FromHANDLE(hwnd), cb->extra); + if (args == NULL) + return FALSE; PyObject *ret = PyEval_CallObject(cb->func, args); - Py_XDECREF(args); - if (ret && PyInt_Check(ret)) + Py_DECREF(args); + if (ret == NULL) + return FALSE; + if (ret != Py_None){ result = PyInt_AsLong(ret); - Py_XDECREF(ret); + if (result == -1 && PyErr_Occurred()) + result = FALSE; + } + Py_DECREF(ret); return result; } -// @pyswig |EnumWindows|Enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE +// @pyswig |EnumWindows|Enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. static PyObject *PyEnumWindows(PyObject *self, PyObject *args) { BOOL rc; PyObject *obFunc, *obOther; - // @pyparm object|callback||A Python function to be used as the callback. + // @pyparm function|callback||A Python function to be used as the callback. Function can return False to stop enumeration, or raise an exception. // @pyparm object|extra||Any python object - this is passed to the callback function as the second param (first is the hwnd). if (!PyArg_ParseTuple(args, "OO", &obFunc, &obOther)) return NULL; @@ -2093,8 +2100,12 @@ Py_BEGIN_ALLOW_THREADS rc = EnumWindows(PyEnumWindowsProc, (LPARAM)&cb); Py_END_ALLOW_THREADS - if (!rc) + if (!rc){ + // Callback may have raised an exception already + if (PyErr_Occurred()) + return NULL; return PyWin_SetAPIError("EnumWindows"); + } Py_INCREF(Py_None); return Py_None; } |
From: <pyw...@li...> - 2012-08-22 01:34:36
|
changeset d6e31fa65434 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=d6e31fa65434 summary: Fix a couple of places where BSTR used for WCHAR changeset cb8d7cb7982e in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=cb8d7cb7982e summary: Allow property functions to accept full range of ULONG, and make sure no exception is left hanging diffstat: com/win32com/src/extensions/PyIPropertyBag.cpp | 25 +-- com/win32com/src/extensions/PyIPropertySetStorage.cpp | 44 +++--- com/win32com/src/extensions/PyIPropertyStorage.cpp | 106 +++++++---------- win32/src/PyWinTypesmodule.cpp | 5 +- 4 files changed, 81 insertions(+), 99 deletions(-) diffs (truncated from 365 to 300 lines): diff -r d6adf5a1b26e -r cb8d7cb7982e com/win32com/src/extensions/PyIPropertyBag.cpp --- a/com/win32com/src/extensions/PyIPropertyBag.cpp Mon Aug 20 19:51:40 2012 -0400 +++ b/com/win32com/src/extensions/PyIPropertyBag.cpp Tue Aug 21 21:32:33 2012 -0400 @@ -24,7 +24,7 @@ int varType = VT_EMPTY; PyObject *obLog = NULL; PyObject *obName; - // @pyparm string|propName||Name of the property to read. + // @pyparm str|propName||Name of the property to read. // @pyparm int|propType||The type of the object to read. Must be a VT_* Variant Type constant. // @pyparm <o PyIErrorLog>|errorLog|None|The caller's <o PyIErrorLog> object in which the property bag stores any errors that occur during reads. Can be None in which case the caller is not interested in errors. if ( !PyArg_ParseTuple(args, "O|iO:Read", &obName, &varType, &obLog) ) @@ -34,24 +34,22 @@ if ( pIPB == NULL ) return NULL; - BSTR bstrName; - if (!PyWinObject_AsBstr(obName, &bstrName)) return NULL; + TmpWCHAR Name; + if (!PyWinObject_AsWCHAR(obName, &Name)) + return NULL; IErrorLog *pIEL = NULL; if ( obLog != NULL && obLog != Py_None && - !PyCom_InterfaceFromPyObject(obLog, IID_IErrorLog, (LPVOID*)&pIEL, FALSE) ) { - PyWinObject_FreeBstr(bstrName); + !PyCom_InterfaceFromPyObject(obLog, IID_IErrorLog, (LPVOID*)&pIEL, FALSE) ) return NULL; - } VARIANT var; VariantInit(&var); V_VT(&var) = varType; // ### do we need to set anything more? PY_INTERFACE_PRECALL; - HRESULT hr = pIPB->Read(bstrName, &var, pIEL); + HRESULT hr = pIPB->Read(Name, &var, pIEL); if ( pIEL != NULL ) pIEL->Release(); - PyWinObject_FreeBstr(bstrName); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPB, IID_IPropertyBag); @@ -67,7 +65,7 @@ { PyObject *obName; PyObject *obValue; - // @pyparm string|propName||Name of the property to read. + // @pyparm str|propName||Name of the property to read. // @pyparm object|value||The value for the property. The value must be able to be converted to a COM VARIANT. if ( !PyArg_ParseTuple(args, "OO:Write", &obName, &obValue) ) return NULL; @@ -76,17 +74,16 @@ if ( pIPB == NULL ) return NULL; + TmpWCHAR Name; + if ( !PyWinObject_AsWCHAR(obName, &Name)) + return NULL; VARIANT var; if ( !PyCom_VariantFromPyObject(obValue, &var) ) return NULL; - BSTR bstrName; - if ( !PyWinObject_AsBstr(obName, &bstrName)) - return NULL; PY_INTERFACE_PRECALL; - HRESULT hr = pIPB->Write(bstrName, &var); + HRESULT hr = pIPB->Write(Name, &var); VariantClear(&var); - PyWinObject_FreeBstr(bstrName); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPB, IID_IPropertyBag); diff -r d6adf5a1b26e -r cb8d7cb7982e com/win32com/src/extensions/PyIPropertySetStorage.cpp --- a/com/win32com/src/extensions/PyIPropertySetStorage.cpp Mon Aug 20 19:51:40 2012 -0400 +++ b/com/win32com/src/extensions/PyIPropertySetStorage.cpp Tue Aug 21 21:32:33 2012 -0400 @@ -27,7 +27,7 @@ return (IPropertySetStorage *)PyIUnknown::GetI(self); } -// @pymethod |PyIPropertySetStorage|Create|Description of Create. +// @pymethod <o PyIPropertyStorage>|PyIPropertySetStorage|Create|Creates a new property set in the storage object PyObject *PyIPropertySetStorage::Create(PyObject *self, PyObject *args) { IPropertySetStorage *pIPSS = GetI(self); @@ -37,10 +37,10 @@ PyObject *obrfmtid; CLSID pclsid; PyObject *obpclsid; - // @pyparm <o PyIID>|fmtid||Description for fmtid - // @pyparm <o PyIID>|clsid>||Description for clsid - // @pyparm int|grfFlags||Description for grfFlags - // @pyparm int|grfMode||Description for grfMode + // @pyparm <o PyIID>|fmtid||GUID identifying a property set, pythoncom.FMTID_* + // @pyparm <o PyIID>|clsid||CLSID of property set handler, usually same as fmtid + // @pyparm int|Flags||Specifies behaviour of property set, storagecon.PROPSETFLAG_* + // @pyparm int|Mode||Access mode, combination of storagecon.STGM_* flags DWORD grfFlags; DWORD grfMode; IPropertyStorage * ppprstg; @@ -61,7 +61,7 @@ return PyCom_PyObjectFromIUnknown(ppprstg, IID_IPropertyStorage, FALSE); } -// @pymethod |PyIPropertySetStorage|Open|Description of Open. +// @pymethod <o PyIPropertyStorage>|PyIPropertySetStorage|Open|Opens an existing property set PyObject *PyIPropertySetStorage::Open(PyObject *self, PyObject *args) { IPropertySetStorage *pIPSS = GetI(self); @@ -69,15 +69,14 @@ return NULL; FMTID rfmtid; PyObject *obrfmtid; - // @pyparm <o PyIID>|fmtid||Description for fmtid - // @pyparm int|grfMode|STGM_READ \| STGM_SHARE_EXCLUSIVE|Description for grfMode + // @pyparm <o PyIID>|fmtid||GUID of a property set, pythoncom.FMTID_* + // @pyparm int|Mode|STGM_READ \| STGM_SHARE_EXCLUSIVE|Access mode, combination of storagecon.STGM_* flags DWORD grfMode=STGM_READ | STGM_SHARE_EXCLUSIVE; IPropertyStorage * ppprstg; if ( !PyArg_ParseTuple(args, "O|l:Open", &obrfmtid, &grfMode) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsIID( obrfmtid, &rfmtid )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsIID( obrfmtid, &rfmtid )) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIPSS->Open( rfmtid, grfMode, &ppprstg ); @@ -89,7 +88,7 @@ return PyCom_PyObjectFromIUnknown(ppprstg, IID_IPropertyStorage, FALSE); } -// @pymethod |PyIPropertySetStorage|Delete|Description of Delete. +// @pymethod |PyIPropertySetStorage|Delete|Removes a property set from this storage object PyObject *PyIPropertySetStorage::Delete(PyObject *self, PyObject *args) { IPropertySetStorage *pIPSS = GetI(self); @@ -97,12 +96,11 @@ return NULL; FMTID rfmtid; PyObject *obrfmtid; - // @pyparm <o PyIID>|fmtid||Description for fmtid + // @pyparm <o PyIID>|fmtid||GUID of a property set, pythoncom.FMTID_* if ( !PyArg_ParseTuple(args, "O:Delete", &obrfmtid) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsIID( obrfmtid, &rfmtid )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsIID( obrfmtid, &rfmtid )) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIPSS->Delete( rfmtid ); @@ -112,10 +110,9 @@ return PyCom_BuildPyException(hr, pIPSS, IID_IPropertySetStorage); Py_INCREF(Py_None); return Py_None; - } -// @pymethod |PyIPropertySetStorage|Enum|Description of Enum. +// @pymethod <o PyIEnumSTATPROPSETSTG>|PyIPropertySetStorage|Enum|Creates an iterator to enumerate contained property sets PyObject *PyIPropertySetStorage::Enum(PyObject *self, PyObject *args) { IPropertySetStorage *pIPSS = GetI(self); @@ -135,13 +132,14 @@ return PyCom_PyObjectFromIUnknown(ppenum, IID_IEnumSTATPROPSETSTG, FALSE); } -// @object PyIPropertySetStorage|Description of the interface +// @object PyIPropertySetStorage|Container for a collection of property sets. +// Can be iterated over to enumerate property sets. static struct PyMethodDef PyIPropertySetStorage_methods[] = { - { "Create", PyIPropertySetStorage::Create, 1 }, // @pymeth Create|Description of Create - { "Open", PyIPropertySetStorage::Open, 1 }, // @pymeth Open|Description of Open - { "Delete", PyIPropertySetStorage::Delete, 1 }, // @pymeth Delete|Description of Delete - { "Enum", PyIPropertySetStorage::Enum, 1 }, // @pymeth Enum|Description of Enum + { "Create", PyIPropertySetStorage::Create, 1 }, // @pymeth Create|Creates a new property set in the storage object + { "Open", PyIPropertySetStorage::Open, 1 }, // @pymeth Open|Opens an existing property set + { "Delete", PyIPropertySetStorage::Delete, 1 }, // @pymeth Delete|Removes a property set from this storage object + { "Enum", PyIPropertySetStorage::Enum, 1 }, // @pymeth Enum|Creates an iterator to enumerate contained property sets { NULL } }; diff -r d6adf5a1b26e -r cb8d7cb7982e com/win32com/src/extensions/PyIPropertyStorage.cpp --- a/com/win32com/src/extensions/PyIPropertyStorage.cpp Mon Aug 20 19:51:40 2012 -0400 +++ b/com/win32com/src/extensions/PyIPropertyStorage.cpp Tue Aug 21 21:32:33 2012 -0400 @@ -10,67 +10,49 @@ // @doc - This file contains autoduck documentation // --------------------------------------------------- +void PyObject_FreePROPSPECs(PROPSPEC *pFree, ULONG cFree) +{ + if (!pFree) + return; + for (ULONG i=0; i<cFree; i++) + if (pFree[i].ulKind == PRSPEC_LPWSTR && pFree[i].lpwstr) + PyWinObject_FreeWCHAR(pFree[i].lpwstr); + free(pFree); +} + // @object PROPSPEC|Identifies a property. Can be either an int property id, or a str/unicode property name. BOOL PyObject_AsPROPSPECs( PyObject *ob, PROPSPEC **ppRet, ULONG *pcRet) { - BOOL ret=FALSE; - DWORD len, i; - PyObject *tuple=PyWinSequence_Tuple(ob, &len); + TmpPyObject tuple=PyWinSequence_Tuple(ob, pcRet); if (tuple==NULL) return FALSE; - - // First count the items, and the total string space we need. - size_t cChars = 0; - for (i=0;i<len;i++) { - PyObject *sub = PyTuple_GET_ITEM(tuple, i); - if (PyUnicode_Check(sub)) - cChars += PyUnicode_GET_SIZE(sub) + 1; - else if (PyString_Check(sub)) - cChars += PyString_Size(sub) + 1; - else if (PyInt_Check(sub)) - ; // PROPID is a ULONG, so this may fail for values that require a python long - else { - PyErr_SetString(PyExc_TypeError, "PROPSPECs must be a sequence of strings or integers"); - goto cleanup; + size_t numBytes = sizeof(PROPSPEC) * *pcRet; + *ppRet = (PROPSPEC *)malloc(numBytes); + if (*ppRet==NULL) { + PyErr_NoMemory(); + return FALSE; + } + ZeroMemory(*ppRet, numBytes); + for (DWORD i=0; i<*pcRet; i++) { + PyObject *sub = PyTuple_GET_ITEM((PyObject *)tuple, i); + (*ppRet)[i].propid = PyInt_AsUnsignedLongMask(sub); + if ((*ppRet)[i].propid != (ULONG)-1 || !PyErr_Occurred()) + (*ppRet)[i].ulKind = PRSPEC_PROPID; + else{ + PyErr_Clear(); + (*ppRet)[i].lpwstr = NULL; + if (PyWinObject_AsWCHAR(sub, &(*ppRet)[i].lpwstr)) + (*ppRet)[i].ulKind = PRSPEC_LPWSTR; + else{ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, "PROPSPECs must be a sequence of strings or integers"); + PyObject_FreePROPSPECs(*ppRet, *pcRet); + *ppRet=NULL; + return FALSE; + } + } } - } - size_t numBytes; - numBytes = (sizeof(PROPSPEC) * len) + (sizeof(WCHAR) * cChars); - PROPSPEC *pRet; - pRet = (PROPSPEC *)malloc(numBytes); - if (pRet==NULL) { - PyErr_SetString(PyExc_MemoryError, "allocating PROPSPECs"); - goto cleanup; - } - WCHAR *curBuf; - curBuf = (WCHAR *)(pRet+len); - for (i=0;i<len;i++) { - PyObject *sub = PyTuple_GET_ITEM(tuple, i); - BSTR bstr; - if (PyWinObject_AsBstr(sub, &bstr)) { - pRet[i].ulKind = PRSPEC_LPWSTR; - pRet[i].lpwstr = curBuf; - wcscpy( curBuf, bstr); - curBuf += wcslen(curBuf) + 1; - PyWinObject_FreeBstr(bstr); - } else { - PyErr_Clear(); - pRet[i].ulKind = PRSPEC_PROPID; - pRet[i].propid = PyInt_AsLong(sub); - } - } - ret=TRUE; - *ppRet = pRet; - *pcRet = len; -cleanup: - Py_DECREF(tuple); - return ret; -} - -void PyObject_FreePROPSPECs(PROPSPEC *pFree, ULONG /*cFree*/) -{ - if (pFree) - free(pFree); + return TRUE; } // Generic conversion from VT_VECTOR arrays to list. @@ -428,7 +410,8 @@ return (IPropertyStorage *)PyIUnknown::GetI(self); } -// @pymethod |PyIPropertyStorage|ReadMultiple|Reads specified properties from the current property set. +// @pymethod (object, ...)|PyIPropertyStorage|ReadMultiple|Reads specified properties from the current property set. |
From: <pyw...@li...> - 2012-08-20 23:59:41
|
changeset b1b93d64ad96 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=b1b93d64ad96 summary: Fix a couple of places where BSTR used for WCHAR; GetCurFile should return changeset b44ca63464fc in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=b44ca63464fc summary: Fix a couple of places where BSTR used for WCHAR changeset aff790ba4fba in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=aff790ba4fba summary: Fix a couple of places where BSTR used for WCHAR changeset d6adf5a1b26e in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=d6adf5a1b26e summary: Fix DWORD conversion in Python 2.3 diffstat: SWIG/swig_lib/python/pywintypes.i | 13 ++- com/win32com/src/extensions/PyIPersistFile.cpp | 69 ++++++--------- com/win32comext/shell/src/PyIExplorerBrowser.cpp | 37 +++----- com/win32comext/shell/src/PyIShellBrowser.cpp | 13 +- com/win32comext/shell/src/PyIShellIconOverlayManager.cpp | 35 +++----- 5 files changed, 73 insertions(+), 94 deletions(-) diffs (truncated from 356 to 300 lines): diff -r 54ec13f605a5 -r d6adf5a1b26e SWIG/swig_lib/python/pywintypes.i --- a/SWIG/swig_lib/python/pywintypes.i Mon Aug 20 02:23:41 2012 -0400 +++ b/SWIG/swig_lib/python/pywintypes.i Mon Aug 20 19:51:40 2012 -0400 @@ -47,7 +47,18 @@ // PyLong_AsUnsignedLongMask isn't ideal - no overflow checking - but // this is what the 'k' format specifier in PyArg_ParseTuple uses, and // that is what much of pywin32 uses for DWORDS, so we use it here too - $target = PyLong_AsUnsignedLongMask($source); + // Also, Python 2.3 and below will not accept a plain int for the PyLong_* functions + #if (PY_VERSION_HEX < 0x02400000) + { + PyObject *tmpLong = PyNumber_Long($source); + if (tmpLong == NULL) + return NULL; + $target = PyLong_AsUnsignedLongMask(tmpLong); + Py_DECREF(tmpLong); + } + #else + $target = PyLong_AsUnsignedLongMask($source); + #endif if ($target==(DWORD)-1 && PyErr_Occurred()) return NULL; } diff -r 54ec13f605a5 -r d6adf5a1b26e com/win32com/src/extensions/PyIPersistFile.cpp --- a/com/win32com/src/extensions/PyIPersistFile.cpp Mon Aug 20 02:23:41 2012 -0400 +++ b/com/win32com/src/extensions/PyIPersistFile.cpp Mon Aug 20 19:51:40 2012 -0400 @@ -52,27 +52,24 @@ IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; - // @pyparm <o unicode>|pszFileName||Absolute path of the file to open - // @pyparm int|dwMode|STGM_READ|Specifies the access mode from the STGM enumeration. - PyObject *obpszFileName; - LPOLESTR pszFileName; + // @pyparm str|FileName||Absolute path of the file to open + // @pyparm int|Mode|STGM_READ|Specifies the access mode from the STGM enumeration. + PyObject *obFileName; + TmpWCHAR FileName; DWORD dwMode = STGM_READ; - if ( !PyArg_ParseTuple(args, "O|l:Load", &obpszFileName, &dwMode) ) + if ( !PyArg_ParseTuple(args, "O|l:Load", &obFileName, &dwMode) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (!PyWinObject_AsBstr(obpszFileName, &pszFileName)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obFileName, &FileName)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIPF->Load( pszFileName, dwMode ); + hr = pIPF->Load(FileName, dwMode ); PY_INTERFACE_POSTCALL; - SysFreeString(pszFileName); if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIPersistFile|Save|Saves the object into the specified file. @@ -81,27 +78,24 @@ IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; - // @pyparm <o unicode>|pszFileName||absolute path of the file where the object is saved. + // @pyparm str|FileName||absolute path of the file where the object is saved. // @pyparm int|fRemember||Specifies whether the file is to be the current working file or not. - PyObject *obpszFileName; - LPOLESTR pszFileName; + PyObject *obFileName; + TmpWCHAR FileName; BOOL fRemember; - if ( !PyArg_ParseTuple(args, "Oi:Save", &obpszFileName, &fRemember) ) + if ( !PyArg_ParseTuple(args, "Oi:Save", &obFileName, &fRemember) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (!PyWinObject_AsBstr(obpszFileName, &pszFileName, TRUE)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obFileName, &FileName, TRUE)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIPF->Save( pszFileName, fRemember ); + hr = pIPF->Save(FileName, fRemember ); PY_INTERFACE_POSTCALL; - SysFreeString(pszFileName); if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIPersistFile|SaveCompleted|Notifies the object that it can revert from NoScribble mode to Normal mode. @@ -110,28 +104,25 @@ IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; - // @pyparm <o unicode>|pszFileName||Absolute path of the file where the object was saved. - PyObject *obpszFileName; - LPOLESTR pszFileName; - if ( !PyArg_ParseTuple(args, "O:SaveCompleted", &obpszFileName) ) + // @pyparm str|FileName||Absolute path of the file where the object was saved. + PyObject *obFileName; + TmpWCHAR FileName; + if ( !PyArg_ParseTuple(args, "O:SaveCompleted", &obFileName) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (!PyWinObject_AsBstr(obpszFileName, &pszFileName)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obFileName, &FileName)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIPF->SaveCompleted( pszFileName ); + hr = pIPF->SaveCompleted(FileName ); PY_INTERFACE_POSTCALL; - SysFreeString(pszFileName); if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); Py_INCREF(Py_None); return Py_None; - } -// @pymethod <o unicode>|PyIPersistFile|GetCurFile|Gets the current name of the file associated with the object. +// @pymethod str|PyIPersistFile|GetCurFile|Gets the current name of the file associated with the object. PyObject *PyIPersistFile::GetCurFile(PyObject *self, PyObject *args) { IPersistFile *pIPF = GetI(self); @@ -147,11 +138,7 @@ if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); - PyObject *obppszFileName; - - obppszFileName = MakeOLECHARToObj(ppszFileName); - PyObject *pyretval = Py_BuildValue("O", obppszFileName); - Py_XDECREF(obppszFileName); + PyObject *pyretval = MakeOLECHARToObj(ppszFileName); CoTaskMemFree(ppszFileName); return pyretval; } @@ -227,10 +214,10 @@ if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params PyObject *obppszFileName; - if (!PyArg_Parse(result, "O" , &obppszFileName)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); - BOOL bPythonIsHappy = TRUE; - if (!PyWinObject_AsBstr(obppszFileName, ppszFileName)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); + if (!PyArg_Parse(result, "O" , &obppszFileName)) + hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); + else if (!PyWinObject_AsTaskAllocatedWCHAR(obppszFileName, ppszFileName)) + hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; } diff -r 54ec13f605a5 -r d6adf5a1b26e com/win32comext/shell/src/PyIExplorerBrowser.cpp --- a/com/win32comext/shell/src/PyIExplorerBrowser.cpp Mon Aug 20 02:23:41 2012 -0400 +++ b/com/win32comext/shell/src/PyIExplorerBrowser.cpp Mon Aug 20 19:51:40 2012 -0400 @@ -113,26 +113,22 @@ IExplorerBrowser *pIEB = GetI(self); if ( pIEB == NULL ) return NULL; - // @pyparm <o unicode>|pszPropertyBag||Description for pszPropertyBag - PyObject *obpszPropertyBag; - LPWSTR pszPropertyBag; - if ( !PyArg_ParseTuple(args, "O:SetPropertyBag", &obpszPropertyBag) ) + // @pyparm str|PropertyBag||Description for pszPropertyBag + PyObject *obPropertyBag; + TmpWCHAR PropertyBag; + if ( !PyArg_ParseTuple(args, "O:SetPropertyBag", &obPropertyBag) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsBstr(obpszPropertyBag, &pszPropertyBag)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obPropertyBag, &PropertyBag)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIEB->SetPropertyBag( pszPropertyBag ); - SysFreeString(pszPropertyBag); - + hr = pIEB->SetPropertyBag(PropertyBag ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEB, IID_IExplorerBrowser ); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIExplorerBrowser|SetEmptyText|Description of SetEmptyText. @@ -141,26 +137,23 @@ IExplorerBrowser *pIEB = GetI(self); if ( pIEB == NULL ) return NULL; - // @pyparm <o unicode>|pszEmptyText||Description for pszEmptyText - PyObject *obpszEmptyText; - LPWSTR pszEmptyText; - if ( !PyArg_ParseTuple(args, "O:SetEmptyText", &obpszEmptyText) ) + // @pyparm str|EmptyText||Description for pszEmptyText + PyObject *obEmptyText; + TmpWCHAR EmptyText; + if ( !PyArg_ParseTuple(args, "O:SetEmptyText", &obEmptyText) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsBstr(obpszEmptyText, &pszEmptyText)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + + if (!PyWinObject_AsWCHAR(obEmptyText, &EmptyText)) + return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pIEB->SetEmptyText( pszEmptyText ); - SysFreeString(pszEmptyText); - + hr = pIEB->SetEmptyText(EmptyText ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEB, IID_IExplorerBrowser ); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIExplorerBrowser|SetFolderSettings|Description of SetFolderSettings. diff -r 54ec13f605a5 -r d6adf5a1b26e com/win32comext/shell/src/PyIShellBrowser.cpp --- a/com/win32comext/shell/src/PyIShellBrowser.cpp Mon Aug 20 02:23:41 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellBrowser.cpp Mon Aug 20 19:51:40 2012 -0400 @@ -121,25 +121,22 @@ IShellBrowser *pISB = GetI(self); if ( pISB == NULL ) return NULL; - PyObject *obpszStatusText; - LPOLESTR pszStatusText; + PyObject *obStatusText; + TmpWCHAR StatusText; if (!PyArg_ParseTuple(args, "O:SetStatusTextSB", - &obpszStatusText)) // @pyparm <o PyUnicode>|pszStatusText||New status to be displayed + &obStatusText)) // @pyparm str|pszStatusText||New status to be displayed return NULL; - if (!PyWinObject_AsBstr(obpszStatusText, &pszStatusText)) + if (!PyWinObject_AsWCHAR(obStatusText, &StatusText)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; - hr = pISB->SetStatusTextSB( pszStatusText ); - SysFreeString(pszStatusText); - + hr = pISB->SetStatusTextSB(StatusText ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); Py_INCREF(Py_None); return Py_None; - } // @pymethod |PyIShellBrowser|EnableModelessSB|Enables or disables modeless dialogs diff -r 54ec13f605a5 -r d6adf5a1b26e com/win32comext/shell/src/PyIShellIconOverlayManager.cpp --- a/com/win32comext/shell/src/PyIShellIconOverlayManager.cpp Mon Aug 20 02:23:41 2012 -0400 +++ b/com/win32comext/shell/src/PyIShellIconOverlayManager.cpp Mon Aug 20 19:51:40 2012 -0400 @@ -24,37 +24,32 @@ return (IShellIconOverlayManager *)PyIUnknown::GetI(self); } -// @pymethod |PyIShellIconOverlayManager|GetFileOverlayInfo|Description of GetFileOverlayInfo. +// @pymethod int|PyIShellIconOverlayManager|GetFileOverlayInfo|Returns an index into the system image list for the icon image or overlay image PyObject *PyIShellIconOverlayManager::GetFileOverlayInfo(PyObject *self, PyObject *args) { IShellIconOverlayManager *pISIOM = GetI(self); if ( pISIOM == NULL ) return NULL; - // @pyparm <o unicode>|path||Description for path - // @pyparm int|attrib||Description for attrib - // @pyparm int|flags||Description for flags + // @pyparm str|path||Full path to the file + // @pyparm int|attrib||File attributes (win32com.FILE_ATTRIBUTE_*) + // @pyparm int|flags||SIOM_OVERLAYINDEX (1) or SIOM_ICONINDEX (2) PyObject *obpath; - LPWSTR path; + TmpWCHAR path; DWORD attrib; int index; DWORD flags; if ( !PyArg_ParseTuple(args, "Oll:GetFileOverlayInfo", &obpath, &attrib, &flags) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsBstr(obpath, &path)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; + if (!PyWinObject_AsWCHAR(obpath, &path)) |