pywin32-checkins Mailing List for Python for Windows Extensions (Page 132)
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: Mark H. <mha...@us...> - 2004-06-12 13:40:41
|
Update of /cvsroot/pywin32/pywin32/AutoDuck In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11940/AutoDuck Modified Files: pywin32.mak Log Message: New win32inet and win32inetcon modules - extensions to the wininet "Internet" APIs. Index: pywin32.mak =================================================================== RCS file: /cvsroot/pywin32/pywin32/AutoDuck/pywin32.mak,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pywin32.mak 28 Apr 2004 03:18:36 -0000 1.4 --- pywin32.mak 12 Jun 2004 13:40:33 -0000 1.5 *************** *** 36,40 **** $(GENDIR)/win32evtlog.d $(GENDIR)/win32event.d $(GENDIR)/win32file.d \ $(GENDIR)/win32service.d $(GENDIR)/win32pipe.d $(GENDIR)/win32security.d \ ! $(GENDIR)/win32process.d $(GENDIR)/wincerapi.d $(GENDIR)/win32gui.d WIN32COM_SOURCE = \ --- 36,41 ---- $(GENDIR)/win32evtlog.d $(GENDIR)/win32event.d $(GENDIR)/win32file.d \ $(GENDIR)/win32service.d $(GENDIR)/win32pipe.d $(GENDIR)/win32security.d \ ! $(GENDIR)/win32process.d $(GENDIR)/wincerapi.d $(GENDIR)/win32gui.d \ ! $(GENDIR)/win32inet.d WIN32COM_SOURCE = \ *************** *** 105,108 **** --- 106,112 ---- ## win32 generated ## + $(GENDIR)/win32inet.d: $(WIN32_SOURCE_DIR)/win32inet.i + $(PYTHON) makedfromi.py -o$*.d $(WIN32_SOURCE_DIR)/$(*B).i + $(GENDIR)/win32file.d: $(WIN32_SOURCE_DIR)/win32file.i $(PYTHON) makedfromi.py -o$*.d $(WIN32_SOURCE_DIR)/$(*B).i |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:40:41
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11940 Modified Files: Python and Extensions.dsw setup_win32all.py Log Message: New win32inet and win32inetcon modules - extensions to the wininet "Internet" APIs. Index: Python and Extensions.dsw =================================================================== RCS file: /cvsroot/pywin32/pywin32/Python and Extensions.dsw,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Python and Extensions.dsw 10 Apr 2004 05:19:56 -0000 1.16 --- Python and Extensions.dsw 12 Jun 2004 13:40:33 -0000 1.17 *************** *** 841,844 **** --- 841,856 ---- ############################################################################### + Project: "win32inet"=.\win32\win32inet.dsp - Package Owner=<4> + + Package=<5> + {{{ + }}} + + Package=<4> + {{{ + }}} + + ############################################################################### + Global: Index: setup_win32all.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** setup_win32all.py 6 May 2004 03:41:27 -0000 1.19 --- setup_win32all.py 12 Jun 2004 13:40:33 -0000 1.20 *************** *** 294,298 **** % (ext.windows_h_version, self.windows_h_version) ! common_dirs = self.compiler.library_dirs common_dirs += os.environ.get("LIB").split(os.pathsep) patched_libs = [] --- 294,298 ---- % (ext.windows_h_version, self.windows_h_version) ! common_dirs = self.compiler.library_dirs[:] common_dirs += os.environ.get("LIB").split(os.pathsep) patched_libs = [] *************** *** 720,723 **** --- 720,724 ---- ("win32trace", "advapi32", False), ("win32wnet", "netapi32 mpr", False), + ("win32inet", "wininet", False), ): |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:35:59
|
Update of /cvsroot/pywin32/pywin32/AutoDuck In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4998 Modified Files: makedfromi.py Log Message: Handle continuations for @pyswig elements, and correct contination detection. Index: makedfromi.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/AutoDuck/makedfromi.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** makedfromi.py 26 Jan 2004 23:37:01 -0000 1.3 --- makedfromi.py 12 Jun 2004 13:35:50 -0000 1.4 *************** *** 6,10 **** def GetComments(line, lineNo, lines): ! # Get the comment from this and continouos lines, if they exist. data = string.split(line, "//", 2) doc = "" --- 6,10 ---- def GetComments(line, lineNo, lines): ! # Get the comment from this and continuos lines, if they exist. data = string.split(line, "//", 2) doc = "" *************** *** 18,21 **** --- 18,24 ---- if string.strip(data[0]): break # Not a continutation! + if data[1].strip().startswith("@"): + # new command + break doc = doc + "\n// " + string.strip(data[1]) lineNo = lineNo + 1 *************** *** 48,52 **** modDoc = string.strip(extra[1]) elif line[:10]=="// @pyswig": ! curMethod = string.strip(line[10:]), [] methods.append(curMethod) elif line[:11]=="// @pymeth ": --- 51,56 ---- modDoc = string.strip(extra[1]) elif line[:10]=="// @pyswig": ! doc, lineNo = GetComments(line, lineNo, lines) ! curMethod = doc[8:], [] methods.append(curMethod) elif line[:11]=="// @pymeth ": *************** *** 95,99 **** if len(fields)<>3: print "**Error - %s does not have enough fields" % meth ! outFile.write("\n// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2])) for extra in extras: outFile.write(extra) --- 99,104 ---- if len(fields)<>3: print "**Error - %s does not have enough fields" % meth ! else: ! outFile.write("\n// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2])) for extra in extras: outFile.write(extra) |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:32:01
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1796/extensions Modified Files: PyIDataObject.cpp PySTGMEDIUM.cpp Log Message: Correctly copy the STGMEDIUM data to the new STGMEDIUM, and not just the pointers. Index: PySTGMEDIUM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PySTGMEDIUM.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PySTGMEDIUM.cpp 26 Apr 2004 00:17:58 -0000 1.4 --- PySTGMEDIUM.cpp 12 Jun 2004 13:31:50 -0000 1.5 *************** *** 136,139 **** --- 136,196 ---- } + BOOL PySTGMEDIUM::CopyTo(STGMEDIUM *pDest) + { + assert(pDest->tymed==0); + switch (medium.tymed) { + // we can't just copy these handles, and there is no easy way I see + // to generically duplicate them. There is a CopyStgMedium function, + // but is part of IE, not of OLE. + case TYMED_GDI: + PyErr_SetString(PyExc_ValueError, "don't know how to copy these objects"); + return FALSE; + // is it ok to just copy these handles? + pDest->hBitmap = medium.hBitmap; + break; + case TYMED_MFPICT: + pDest->hMetaFilePict = medium.hMetaFilePict; + break; + case TYMED_ENHMF: + pDest->hEnhMetaFile = medium.hEnhMetaFile; + break; + case TYMED_HGLOBAL: { + UINT cb = GlobalSize(medium.hGlobal); + pDest->hGlobal = GlobalAlloc(GMEM_FIXED, cb); + if (!pDest->hGlobal) { + PyErr_NoMemory(); + return FALSE; + } + memcpy(pDest->hGlobal, medium.hGlobal, cb); + break; + } + case TYMED_FILE: + if (medium.lpszFileName) { + int cch = wcslen(medium.lpszFileName) + 1; + if (!(pDest->lpszFileName = (WCHAR *)CoTaskMemAlloc(sizeof(WCHAR) * cch))) { + PyErr_NoMemory(); + return FALSE; + } + wcsncpy(pDest->lpszFileName, medium.lpszFileName, cch); + } + break; + case TYMED_ISTREAM: + pDest->pstm = medium.pstm; + if (pDest->pstm) pDest->pstm->AddRef(); + break; + case TYMED_ISTORAGE: + pDest->pstg = medium.pstg; + if (pDest->pstg) pDest->pstg->AddRef(); + break; + case TYMED_NULL: + // nothing to do + break; + default: + PyErr_Format(PyExc_ValueError, "Unknown tymed value '%d'", medium.tymed); + return FALSE; + } + pDest->tymed = medium.tymed; + return TRUE; + } void PySTGMEDIUM::Close() { Index: PyIDataObject.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIDataObject.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIDataObject.cpp 25 Apr 2004 04:10:48 -0000 1.4 --- PyIDataObject.cpp 12 Jun 2004 13:31:50 -0000 1.5 *************** *** 332,337 **** if (PySTGMEDIUM_Check(result)) { PySTGMEDIUM *pym = (PySTGMEDIUM *)result; ! memcpy(pmedium, &pym->medium, sizeof(STGMEDIUM)); ! pym->DropOwnership(); } hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); --- 332,336 ---- if (PySTGMEDIUM_Check(result)) { PySTGMEDIUM *pym = (PySTGMEDIUM *)result; ! pym->CopyTo(pmedium); } hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:32:01
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1796/include Modified Files: PyComTypeObjects.h Log Message: Correctly copy the STGMEDIUM data to the new STGMEDIUM, and not just the pointers. Index: PyComTypeObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PyComTypeObjects.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyComTypeObjects.h 25 Apr 2004 04:10:48 -0000 1.3 --- PyComTypeObjects.h 12 Jun 2004 13:31:51 -0000 1.4 *************** *** 128,131 **** --- 128,132 ---- void DropOwnership(void); void Close(void); + BOOL CopyTo(STGMEDIUM *pDest); static void deallocFunc(PyObject *ob); static PyObject *getattr(PyObject *self, char *name); |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:29:39
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/mapi/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv574 Modified Files: PyIMAPITable.i Log Message: Autoduck corrections. Index: PyIMAPITable.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/mapi/src/PyIMAPITable.i,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIMAPITable.i 1 Sep 1999 23:17:16 -0000 1.1 --- PyIMAPITable.i 12 Jun 2004 13:29:31 -0000 1.2 *************** *** 94,98 **** ); ! // @pyswig|Abort|Stops any asynchronous operations currently in progress for the table. HRESULT Abort(); --- 94,98 ---- ); ! // @pyswig |Abort|Stops any asynchronous operations currently in progress for the table. HRESULT Abort(); |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:28:23
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31843 Modified Files: PyIShellBrowser.cpp Log Message: Autoduck corrections. Index: PyIShellBrowser.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellBrowser.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIShellBrowser.cpp 26 May 2004 08:57:02 -0000 1.4 --- PyIShellBrowser.cpp 12 Jun 2004 13:28:15 -0000 1.5 *************** *** 405,408 **** --- 405,409 ---- } + // @object PyIShellBrowser|Exposed by Windows Explorer and the Open File common dialog box to provide services for namespace extensions. static struct PyMethodDef PyIShellBrowser_methods[] = { |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:27:44
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31210 Modified Files: shell.cpp Log Message: Add ShellExecuteEx Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** shell.cpp 26 May 2004 08:55:55 -0000 1.26 --- shell.cpp 12 Jun 2004 13:27:35 -0000 1.27 *************** *** 1487,1491 **** if (mask1 & mask2 ) PyDict_SetItemString(ret, #x, state.x ? Py_True : Py_False); ! // @pymethod dict|SHGetSettings|Retrieves the current shell option settings. static PyObject *PySHGetSettings(PyObject *self, PyObject *args) { --- 1487,1491 ---- if (mask1 & mask2 ) PyDict_SetItemString(ret, #x, state.x ? Py_True : Py_False); ! // @pymethod dict|shell|SHGetSettings|Retrieves the current shell option settings. static PyObject *PySHGetSettings(PyObject *self, PyObject *args) { *************** *** 1520,1524 **** } return ret; ! // @rdesc, the resule is a dictionary, the contents of which depend on // the mask param. Key names are the same as the SHELLFLAGSTATE // structure members - 'fShowExtensions', 'fNoConfirmRecycle', etc --- 1520,1524 ---- } return ret; ! // @rdesc The result is a dictionary, the contents of which depend on // the mask param. Key names are the same as the SHELLFLAGSTATE // structure members - 'fShowExtensions', 'fNoConfirmRecycle', etc *************** *** 1818,1821 **** --- 1818,1925 ---- } + // @pymethod dict|shell|ShellExecuteEx|Performs an operation on a file. + static PyObject *PyShellExecuteEx(PyObject *self, PyObject *args, PyObject *kw) + { + PyObject *ret = NULL; + BOOL ok; + SHELLEXECUTEINFO *p = (SHELLEXECUTEINFO *)malloc(sizeof(*p)); + if (!p) + return PyErr_NoMemory(); + + memset(p, 0, sizeof(*p)); + p->cbSize = sizeof(*p); + + static char *kw_items[]= { + "fMask","hwnd","lpVerb","lpFile", "lpParameters", "lpDirectory", + "nShow", "lpIDList", "lpClass", "hkeyClass", "dwHotKey", + "hIcon", "hMonitor", NULL, + }; + PyObject *obVerb = NULL, *obFile = NULL, *obParams = NULL; + PyObject *obDirectory = NULL, *obIDList = NULL, *obClass = NULL; + PyObject *obhkeyClass = NULL, *obHotKey = NULL, *obhIcon = NULL; + PyObject *obhMonitor = NULL; + if (!PyArg_ParseTupleAndKeywords(args, kw, "|llOOOOlOOOOOO", kw_items, + // @pyparm int|fMask|0|The default mask for the + // structure. Other masks may be added based on + // what paramaters are supplied. + &p->fMask, + &p->hwnd, // @pyparm int|hwnd|0| + &obVerb, // @pyparm string|lpVerb|| + &obFile, // @pyparm string|lpFile|| + &obParams, // @pyparm string|lpParams|| + &obDirectory, // @pyparm string|lpDirectory|| + &p->nShow, // @pyparm int|nShow|0| + &obIDList, // @pyparm <o PIDL>|lpIDList|| + &obClass, // @pyparm string|obClass|| + &obhkeyClass, // @pyparm int|hkeyClass|| + &obHotKey, // @pyparm int|dwHotKey|| + &obhIcon, // @pyparm <o PyHANDLE>|hIcon|| + &obhMonitor)) // @pyparm <o PyHANDLE>|hMonitor|| + goto done; + + if (obVerb && !PyWinObject_AsString(obVerb, (char **)&p->lpVerb)) + goto done; + if (obFile && !PyWinObject_AsString(obFile, (char **)&p->lpFile)) + goto done; + if (obParams && !PyWinObject_AsString(obParams, (char **)&p->lpParameters)) + goto done; + if (obDirectory && !PyWinObject_AsString(obDirectory, (char **)&p->lpDirectory)) + goto done; + if (obIDList) { + p->fMask |= SEE_MASK_IDLIST; + if (!PyObject_AsPIDL(obIDList, (ITEMIDLIST **)&p->lpIDList)) + goto done; + } + if (obClass) { + p->fMask |= SEE_MASK_CLASSNAME; + if (!PyWinObject_AsString(obClass, (char **)&p->lpClass)) + goto done; + } + if (obhkeyClass) { + p->fMask |= SEE_MASK_CLASSKEY; + if (!PyWinObject_AsHKEY(obhkeyClass, &p->hkeyClass)) + goto done; + } + if (obHotKey) { + p->fMask |= SEE_MASK_HOTKEY; + p->dwHotKey = PyInt_AsLong(obHotKey); + if (PyErr_Occurred()) + goto done; + } + if (obhIcon) { + p->fMask |= SEE_MASK_ICON; + if (!PyWinObject_AsHANDLE(obhIcon, &p->hIcon)) + goto done; + } + if (obhMonitor) { + p->fMask |= SEE_MASK_HMONITOR; + if (!PyWinObject_AsHANDLE(obhMonitor, &p->hMonitor)) + goto done; + } + { // new scope to avoid warnings about the goto + PY_INTERFACE_PRECALL; + ok = ShellExecuteEx(p); + PY_INTERFACE_POSTCALL; + } + if (ok) { + ret = Py_BuildValue("{s:l,s:N}", + "hInstApp", p->hInstApp, + "hProcess", PyWinObject_FromHANDLE(p->hProcess)); + // @rdesc The result is a dictionary based on documented result values + // in the structure. Currently this is "hInstApp" and "hProcess" + } else + PyWin_SetAPIError("ShellExecuteEx"); + + done: + PyWinObject_FreeString((char *)p->lpVerb); + PyWinObject_FreeString((char *)p->lpFile); + PyWinObject_FreeString((char *)p->lpParameters); + PyWinObject_FreeString((char *)p->lpDirectory); + PyWinObject_FreeString((char *)p->lpClass); + PyObject_FreePIDL((ITEMIDLIST *)p->lpIDList); + return ret; + } + + /* List of module functions */ // @module shell|A module, encapsulating the ActiveX Control interfaces *************** *** 1849,1852 **** --- 1953,1957 ---- { "FILEGROUPDESCRIPTORAsString", PyFILEGROUPDESCRIPTORAsString, 1}, // @pymeth FILEGROUPDESCRIPTORAsString|Creates a FILEGROUPDESCRIPTOR from a sequence of mapping objects, each with FILEDESCRIPTOR attributes { "StringAsFILEGROUPDESCRIPTOR", PyStringAsFILEGROUPDESCRIPTOR, 1}, // @pymeth StringAsFILEGROUPDESCRIPTOR|Decodes a FILEGROUPDESCRIPTOR packed in a string + { "ShellExecuteEx", (PyCFunction)PyShellExecuteEx, METH_VARARGS|METH_KEYWORDS}, // @pymeth ShellExecuteEx|Performs an action on a file. { NULL, NULL }, }; |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:26:10
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29328 Modified Files: test_win32file.py Log Message: Test FindFiles and FindFilesIterator Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_win32file.py 24 Oct 2003 01:50:15 -0000 1.2 --- test_win32file.py 12 Jun 2004 13:26:02 -0000 1.3 *************** *** 4,7 **** --- 4,9 ---- import os import tempfile + import sets + import shutil class TestSimpleOps(unittest.TestCase): *************** *** 109,112 **** --- 111,154 ---- h.Close() + class TestFindFiles(unittest.TestCase): + def testIter(self): + dir = os.path.join(os.getcwd(), "*") + files = win32file.FindFilesW(dir) + set1 = sets.Set() + set1.update(files) + set2 = sets.Set() + for file in win32file.FindFilesIterator(dir): + set2.add(file) + assert len(set2) > 5, "This directory has less than 5 files!?" + self.failUnlessEqual(set1, set2) + + def testBadDir(self): + dir = os.path.join(os.getcwd(), "a dir that doesnt exist", "*") + self.assertRaises(win32file.error, win32file.FindFilesIterator, dir) + + def testEmptySpec(self): + spec = os.path.join(os.getcwd(), "*.foo_bar") + num = 0 + for i in win32file.FindFilesIterator(spec): + print "Got", i + num += 1 + self.failUnlessEqual(0, num) + + def testEmptyDir(self): + test_path = os.path.join(win32api.GetTempPath(), "win32file_test_directory") + try: + shutil.rmtree(test_path) + except os.error: + pass + os.mkdir(test_path) + try: + num = 0 + for i in win32file.FindFilesIterator(os.path.join(test_path, "*")): + num += 1 + # Expecting "." and ".." only + self.failUnlessEqual(2, num) + finally: + shutil.rmtree(test_path) + if __name__ == '__main__': unittest.main() |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:25:06
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27771 Modified Files: PyLARGE_INTEGER.cpp Log Message: Operator precendence bug *still* prevented all values being converted correctly. Index: PyLARGE_INTEGER.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyLARGE_INTEGER.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyLARGE_INTEGER.cpp 26 May 2004 08:51:04 -0000 1.8 --- PyLARGE_INTEGER.cpp 12 Jun 2004 13:24:57 -0000 1.9 *************** *** 101,105 **** { // If it fits in a normal Python int, we return one of them. ! if (hidword==0 && (lodword & 0x8000==0)) return PyInt_FromLong(lodword); else { --- 101,105 ---- { // If it fits in a normal Python int, we return one of them. ! if (hidword==0 && ((lodword & 0x8000)==0)) return PyInt_FromLong(lodword); else { |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:24:18
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27007 Modified Files: PyWinTypesmodule.cpp Log Message: If an extension has registered a hmodule for the error range, use it. Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyWinTypesmodule.cpp 30 Mar 2004 04:14:27 -0000 1.14 --- PyWinTypesmodule.cpp 12 Jun 2004 13:24:08 -0000 1.15 *************** *** 227,241 **** #endif /* error helper - GetLastError() is provided, but this is for exceptions */ PyObject *PyWin_SetAPIError(char *fnName, long err /*= 0*/) { - const int bufSize = 512; - TCHAR buf[bufSize]; DWORD errorCode = err == 0 ? GetLastError() : err; ! BOOL bHaveMessage = FALSE; if (errorCode) ! bHaveMessage = ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errorCode, 0, buf, bufSize, NULL )>0; ! if (!bHaveMessage) ! _tcscpy(buf,_T("No error message is available")); /* strip trailing cr/lf */ int end = _tcslen(buf)-1; --- 227,287 ---- #endif + // Support the fact that error messages can come from any number of DLLs. + // wininet certainly does. The win32net and MAPI modules could probably + // also take advantage of this, + struct error_message_module { + DWORD firstError; + DWORD lastError; + HMODULE hmodule; + }; + + // just allow a limit of 10 for now! + #define MAX_MESSAGE_MODULES 10 + static error_message_module error_message_modules[MAX_MESSAGE_MODULES]; + static int num_message_modules = 0; + + BOOL PyWin_RegisterErrorMessageModule(DWORD first, DWORD last, HINSTANCE hmod) + { + if (num_message_modules>=MAX_MESSAGE_MODULES) { + assert(0); // need a either bump the limit, or make a real implementation! + return FALSE; + } + error_message_modules[num_message_modules].firstError = first; + error_message_modules[num_message_modules].lastError = last; + error_message_modules[num_message_modules].hmodule = hmod; + num_message_modules += 1; + return TRUE; + } + + HINSTANCE PyWin_GetErrorMessageModule(DWORD err) + { + int i; + for (i=0;i<num_message_modules;i++) { + if ((DWORD)err >= error_message_modules[i].firstError && + (DWORD)err <= error_message_modules[i].lastError) { + return error_message_modules[i].hmodule; + } + } + return NULL; + } + /* error helper - GetLastError() is provided, but this is for exceptions */ PyObject *PyWin_SetAPIError(char *fnName, long err /*= 0*/) { DWORD errorCode = err == 0 ? GetLastError() : err; ! DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | \ ! FORMAT_MESSAGE_IGNORE_INSERTS; ! // try and find the hmodule providing this error. ! HMODULE hmodule = PyWin_GetErrorMessageModule(errorCode); ! if (hmodule) ! flags |= FORMAT_MESSAGE_FROM_HMODULE; ! TCHAR *buf = NULL; ! BOOL free_buf = TRUE; if (errorCode) ! ::FormatMessage(flags, hmodule, errorCode, 0, (LPTSTR)&buf, 0, NULL ); ! if (!buf) { ! buf = _T("No error message is available"); ! free_buf = FALSE; ! } /* strip trailing cr/lf */ int end = _tcslen(buf)-1; *************** *** 246,249 **** --- 292,297 ---- buf[end]=_T('\0'); PyObject *obBuf = PyString_FromTCHAR(buf); + if (free_buf && buf) + LocalFree(buf); PyObject *v = Py_BuildValue("(isO)", errorCode, fnName, obBuf); Py_XDECREF(obBuf); |
|
From: Mark H. <mha...@us...> - 2004-06-12 08:56:03
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9142 Modified Files: win32gui.i Log Message: autoduck corrections. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** win32gui.i 12 Jun 2004 07:53:15 -0000 1.42 --- win32gui.i 12 Jun 2004 08:55:50 -0000 1.43 *************** *** 1610,1614 **** // @pyswig HICON|CopyIcon|Copies an icon ! // #pyparm int|hicon||Existing icon HICON CopyIcon(HICON hicon); --- 1610,1614 ---- // @pyswig HICON|CopyIcon|Copies an icon ! // @pyparm int|hicon||Existing icon HICON CopyIcon(HICON hicon); |
|
From: Mark H. <mha...@us...> - 2004-06-12 07:58:38
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21988 Modified Files: win32file.i Log Message: New function 'FindFilesIterator()', which returns an iterator based on FindFirstFile/FindNextFile. The iterator avoids creating a list for the result and is much faster for large directories. Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** win32file.i 3 Mar 2004 20:37:04 -0000 1.38 --- win32file.i 12 Jun 2004 07:58:29 -0000 1.39 *************** *** 343,346 **** --- 343,363 ---- %{ + + PyObject *PyObject_FromFIND_DATA(WIN32_FIND_DATAW *pData) + { + // @object FIND_DATA|A tuple representing a Win32 WIN32_FIND_DATA structure. + return Py_BuildValue("lNNNlllluu", + pData->dwFileAttributes, // @tupleitem 0|int|attributes|File Attributes. A combination of the win32com.FILE_ATTRIBUTE_* flags. + PyWinObject_FromFILETIME(pData->ftCreationTime), // @tupleitem 1|<o PyTime>|createTime|File creation time. + PyWinObject_FromFILETIME(pData->ftLastAccessTime), // @tupleitem 2|<o PyTime>|accessTime|File access time. + PyWinObject_FromFILETIME(pData->ftLastWriteTime), // @tupleitem 3|<o PyTime>|writeTime|Time of last file write + pData->nFileSizeHigh, // @tupleitem 4|int|nFileSizeHigh|high order word of file size. + pData->nFileSizeLow, // @tupleitem 5|int|nFileSizeLow|low order word of file size. + pData->dwReserved0, // @tupleitem 6|int|reserved0|Reserved. + pData->dwReserved1, // @tupleitem 7|int|reserved1|Reserved. + pData->cFileName, // @tupleitem 8|Unicode|fileName|The name of the file. + pData->cAlternateFileName); // @tupleitem 9|Unicode|alternateFilename|Alternative name of the file, expressed in 8.3 format. + } + // @pyswig list|FindFilesW|Retrieves a list of matching filenames, using the Windows Unicode API. An interface to the API FindFirstFileW/FindNextFileW/Find close functions. static PyObject * *************** *** 358,361 **** --- 375,379 ---- HANDLE hFind; + memset(&findData, 0, sizeof(findData)); hFind = ::FindFirstFileW(fileSpec, &findData); PyWinObject_FreeWCHAR(fileSpec); *************** *** 371,411 **** return NULL; } BOOL ok = TRUE; while (ok) { ! PyObject *obCreateTime = PyWinObject_FromFILETIME(findData.ftCreationTime); ! PyObject *obAccessTime = PyWinObject_FromFILETIME(findData.ftLastAccessTime); ! PyObject *obWriteTime = PyWinObject_FromFILETIME(findData.ftLastWriteTime); ! if (obCreateTime==NULL || obAccessTime==NULL || obWriteTime==NULL) { ! Py_XDECREF(obCreateTime); ! Py_XDECREF(obAccessTime); ! Py_XDECREF(obWriteTime); ! Py_DECREF(retList); ::FindClose(hFind); return NULL; } ! PyObject *obName = PyWinObject_FromWCHAR(findData.cFileName); ! PyObject *obAltName = PyWinObject_FromWCHAR(findData.cAlternateFileName); ! PyObject *newItem = Py_BuildValue("lOOOllllOO", ! // @rdesc The return value is a list of tuples, in the same format as the WIN32_FIND_DATA structure: ! findData.dwFileAttributes, // @tupleitem 0|int|attributes|File Attributes. A combination of the win32com.FILE_ATTRIBUTE_* flags. ! obCreateTime, // @tupleitem 1|<o PyTime>|createTime|File creation time. ! obAccessTime, // @tupleitem 2|<o PyTime>|accessTime|File access time. ! obWriteTime, // @tupleitem 3|<o PyTime>|writeTime|Time of last file write ! findData.nFileSizeHigh, // @tupleitem 4|int|nFileSizeHigh|high order word of file size. ! findData.nFileSizeLow, // @tupleitem 5|int|nFileSizeLow|low order word of file size. ! findData.dwReserved0, // @tupleitem 6|int|reserved0|Reserved. ! findData.dwReserved1, // @tupleitem 7|int|reserved1|Reserved. ! obName, // @tupleitem 8|Unicode|fileName|The name of the file. ! obAltName); // @tupleitem 9|Unicode|alternateFilename|Alternative name of the file, expressed in 8.3 format. ! Py_XDECREF(obName); ! Py_XDECREF(obAltName); ! if (newItem!=NULL) { ! PyList_Append(retList, newItem); ! Py_DECREF(newItem); ! } // @pyseeapi FindNextFile ! Py_DECREF(obCreateTime); ! Py_DECREF(obAccessTime); ! Py_DECREF(obWriteTime); ok=::FindNextFileW(hFind, &findData); } --- 389,405 ---- return NULL; } + // @rdesc The return value is a list of <o FIND_DATA> tuples. BOOL ok = TRUE; while (ok) { ! PyObject *newItem = PyObject_FromFIND_DATA(&findData); ! if (!newItem) { ::FindClose(hFind); + Py_DECREF(retList); return NULL; } ! PyList_Append(retList, newItem); ! Py_DECREF(newItem); // @pyseeapi FindNextFile ! memset(&findData, 0, sizeof(findData)); ok=::FindNextFileW(hFind, &findData); } *************** *** 423,426 **** --- 417,551 ---- %native(FindFilesW) PyFindFilesW; + %{ + + typedef struct { + PyObject_HEAD + HANDLE hFind; + WIN32_FIND_DATAW buffer; + BOOL seen_first; + BOOL empty; + } FindFileIterator; + + + static void + ffi_dealloc(FindFileIterator *it) + { + if (it->hFind != INVALID_HANDLE_VALUE) + ::FindClose(it->hFind); + PyObject_Del(it); + } + + static PyObject * + ffi_iternext(PyObject *iterator) + { + FindFileIterator *ffi = (FindFileIterator *)iterator; + if (ffi->empty) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + if (!ffi->seen_first) + ffi->seen_first = TRUE; + else { + BOOL ok; + Py_BEGIN_ALLOW_THREADS + memset(&ffi->buffer, 0, sizeof(ffi->buffer)); + ok = ::FindNextFileW(ffi->hFind, &ffi->buffer); + Py_END_ALLOW_THREADS + if (!ok) { + if (GetLastError()==ERROR_NO_MORE_FILES) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + return PyWin_SetAPIError("FindNextFileW"); + } + } + return PyObject_FromFIND_DATA(&ffi->buffer); + } + + PyTypeObject FindFileIterator_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "FindFileIterator", /* tp_name */ + sizeof(FindFileIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)ffi_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)ffi_iternext, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + }; + + // @pyswig iterator|FindFilesIterator|Returns an interator based on + // FindFirstFile/FindNextFile. Similar to <om win32file.FindFiles>, but + // avoids the creation of the list for huge directories + static PyObject * + PyFindFilesIterator(PyObject *self, PyObject *args) + { + WCHAR *fileSpec; + PyObject *obfileSpec=NULL; + // @pyparm unicode|filespec|| + if (!PyArg_ParseTuple (args, "O:FindFilesIterator", &obfileSpec)) + return NULL; + + if (!PyWinObject_AsWCHAR(obfileSpec,&fileSpec,FALSE)) + return NULL; + + FindFileIterator *it = PyObject_New(FindFileIterator, &FindFileIterator_Type); + if (it == NULL) { + PyWinObject_FreeWCHAR(fileSpec); + return NULL; + } + it->seen_first = FALSE; + it->empty = FALSE; + it->hFind = INVALID_HANDLE_VALUE; + memset(&it->buffer, 0, sizeof(it->buffer)); + + Py_BEGIN_ALLOW_THREADS + it->hFind = ::FindFirstFileW(fileSpec, &it->buffer); + Py_END_ALLOW_THREADS + PyWinObject_FreeWCHAR(fileSpec); + + if (it->hFind==INVALID_HANDLE_VALUE) { + if (::GetLastError()!=ERROR_FILE_NOT_FOUND) { // this is OK + Py_DECREF(it); + return PyWin_SetAPIError("FindNextFileW"); + } + it->empty = TRUE; + } + return (PyObject *)it; + // @rdesc The result is a Python iterator, with each next() method + // returning a <o FIND_DATA> tuple. + } + %} + + %native(FindFilesIterator) PyFindFilesIterator; + + // @pyswig |FlushFileBuffers|Clears the buffers for the specified file and causes all buffered data to be written to the file. BOOLAPI FlushFileBuffers( *************** *** 3039,3042 **** --- 3164,3170 ---- %init %{ + + PyDict_SetItemString(d, "error", PyWinExc_ApiError); + HMODULE hmodule; FARPROC fp; |
|
From: Mark H. <mha...@us...> - 2004-06-12 07:53:24
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19298 Modified Files: win32gui.i Log Message: Add FlashWindow, FlashWindowEx, and autoduck corrections. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** win32gui.i 19 May 2004 10:33:18 -0000 1.41 --- win32gui.i 12 Jun 2004 07:53:15 -0000 1.42 *************** *** 997,1000 **** --- 997,1028 ---- } + // @pyswig int|FlashWindow|The FlashWindow function flashes the specified window one time. It does not change the active state of the window. + // @pyparm int|hwnd|| + // @pyparm int|bInvert|| + BOOL FlashWindow(HWND hwnd, BOOL bInvert); + + %{ + PyObject *PyFlashWindowEx(PyObject *self, PyObject *args) + { + PyObject *ret; + BOOL rc; + FLASHWINFO f; + f.cbSize = sizeof f; + // @pyparm int|hwnd|| + // @pyparm int|dwFlags|| + // @pyparm int|uCount|| + // @pyparm int|dwTimeout|| + if (!PyArg_ParseTuple(args, "iiii", &f.hwnd, &f.dwFlags, &f.uCount, &f.dwTimeout)) + return NULL; + Py_BEGIN_ALLOW_THREADS + rc = FlashWindowEx(&f); + Py_END_ALLOW_THREADS + ret = rc ? Py_True : Py_False; + Py_INCREF(ret); + return ret; + } + %} + %native(FlashWindowEx) PyFlashWindowEx; + // @pyswig int|GetWindowLong| // @pyparm int|hwnd|| *************** *** 2779,2783 **** // @pyparm int|hwnd||The handle to the window // @pyparm object|callback||A callback object, taking 3 params. ! // @pyparm object|param|None||The third param to the callback function. if (!PyArg_ParseTuple(args, "iO|O:ListView_SortItems", &hwnd, &ob, &obParam)) return NULL; --- 2807,2811 ---- // @pyparm int|hwnd||The handle to the window // @pyparm object|callback||A callback object, taking 3 params. ! // @pyparm object|param|None|The third param to the callback function. if (!PyArg_ParseTuple(args, "iO|O:ListView_SortItems", &hwnd, &ob, &obParam)) return NULL; *************** *** 2806,2810 **** // @pyparm int|hwnd||The handle to the window // @pyparm object|callback||A callback object, taking 3 params. ! // @pyparm object|param|None||The third param to the callback function. if (!PyArg_ParseTuple(args, "iO|O:ListView_SortItemsEx", &hwnd, &ob, &obParam)) return NULL; --- 2834,2838 ---- // @pyparm int|hwnd||The handle to the window // @pyparm object|callback||A callback object, taking 3 params. ! // @pyparm object|param|None|The third param to the callback function. if (!PyArg_ParseTuple(args, "iO|O:ListView_SortItemsEx", &hwnd, &ob, &obParam)) return NULL; |
|
From: Mark H. <mha...@us...> - 2004-06-12 07:52:03
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18426 Modified Files: win32netmodule.cpp Log Message: Register the network error range with pywintypes, and remove our local error routine, as pywintypes now does it for us. Index: win32netmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netmodule.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32netmodule.cpp 21 May 2004 04:49:41 -0000 1.15 --- win32netmodule.cpp 12 Jun 2004 07:51:53 -0000 1.16 *************** *** 41,91 **** /* error helpers */ - /* error helper - GetLastError() is provided, but this is for exceptions */ PyObject *ReturnNetError(char *fnName, long err /*=0*/) { - static HMODULE hModule=NULL; - if (hModule==NULL) - hModule = LoadLibraryEx( - TEXT("netmsg.dll"), - NULL, - LOAD_LIBRARY_AS_DATAFILE); - - if (err==0) err = GetLastError(); - if(err >= NERR_BASE && err <= MAX_NERR) { - if(hModule != NULL) { - DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_HMODULE | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ALLOCATE_BUFFER; - - // call FormatMessage() to allow for message text to be acquired - // from the system or the supplied module handle // - WCHAR *szMessage; - DWORD dwResult; - if(dwResult=FormatMessage( - dwFormatFlags, - hModule, // module to get message from (NULL == system) - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR) &szMessage, - 0, - NULL)) { - // remove the \r\n, like the real API - if (dwResult>2) - szMessage[dwResult-2]=_T('\0'); - PyObject *str = PyString_FromUnicode(szMessage); - LocalFree(szMessage); - PyObject *v = Py_BuildValue("(izO)", err, fnName, str ); - Py_DECREF(str); - if (v != NULL) { - PyErr_SetObject(PyWinExc_ApiError, v); - Py_DECREF(v); - return NULL; - } - - } - } - } return PyWin_SetAPIError(fnName, err); }; --- 41,46 ---- *************** *** 1150,1155 **** PyDict_SetItemString(dict, "SERVICE_SERVER", PyUnicode_FromWideChar(SERVICE_SERVER,wcslen(SERVICE_SERVER))); PyDict_SetItemString(dict, "SERVICE_WORKSTATION", PyUnicode_FromWideChar(SERVICE_WORKSTATION,wcslen(SERVICE_WORKSTATION))); ! ! Py_INCREF(PyWinExc_ApiError); AddConstant(dict, "USE_NOFORCE", USE_NOFORCE); AddConstant(dict, "USE_FORCE", USE_FORCE); --- 1105,1113 ---- PyDict_SetItemString(dict, "SERVICE_SERVER", PyUnicode_FromWideChar(SERVICE_SERVER,wcslen(SERVICE_SERVER))); PyDict_SetItemString(dict, "SERVICE_WORKSTATION", PyUnicode_FromWideChar(SERVICE_WORKSTATION,wcslen(SERVICE_WORKSTATION))); ! ! HMODULE hmod = LoadLibraryEx(TEXT("netmsg.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE); ! PyWin_RegisterErrorMessageModule(NERR_BASE, ! MAX_NERR, ! hmod); AddConstant(dict, "USE_NOFORCE", USE_NOFORCE); AddConstant(dict, "USE_FORCE", USE_FORCE); |
|
From: Mark H. <mha...@us...> - 2004-06-12 07:46:03
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13361 Modified Files: PyWinTypes.h win32apimodule.cpp Log Message: Allow an extension to register a hmodule that provides error messages for our standard API error. Used by the win32inet and win32net modules, both of which return error codes with their own range, and with the corresponding messages in their own hmodule. Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** win32apimodule.cpp 9 Apr 2004 11:08:37 -0000 1.36 --- win32apimodule.cpp 12 Jun 2004 07:45:54 -0000 1.37 *************** *** 503,508 **** const int bufSize = 512; char buf[bufSize]; // @pyseeapi FormatMessage ! if (::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errCode, 0, buf, bufSize, NULL )<=0) return ReturnAPIError("FormatMessage"); return Py_BuildValue("s", buf); --- 503,512 ---- const int bufSize = 512; char buf[bufSize]; + DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; + HMODULE hmodule = PyWin_GetErrorMessageModule(errCode); + if (hmodule) + flags |= FORMAT_MESSAGE_FROM_HMODULE; // @pyseeapi FormatMessage ! if (::FormatMessage(flags, hmodule, errCode, 0, buf, bufSize, NULL )<=0) return ReturnAPIError("FormatMessage"); return Py_BuildValue("s", buf); Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PyWinTypes.h 30 Mar 2004 04:38:17 -0000 1.21 --- PyWinTypes.h 12 Jun 2004 07:45:54 -0000 1.22 *************** *** 74,77 **** --- 74,82 ---- */ extern PYWINTYPES_EXPORT PyObject *PyWinExc_ApiError; + // Register a Windows DLL that contains the messages in the specified range. + extern PYWINTYPES_EXPORT BOOL PyWin_RegisterErrorMessageModule(DWORD first, DWORD last, HINSTANCE hmod); + // Get the previously registered hmodule for an error code. + extern PYWINTYPES_EXPORT HINSTANCE PyWin_GetErrorMessageModule(DWORD err); + /* A global function that sets an API style error (ie, (code, fn, errTest)) */ |
|
From: Mark H. <mha...@us...> - 2004-06-08 23:26:21
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13602 Modified Files: sgrepmdi.py Log Message: The update to the RE module was not done correctly - Mike Kelly provided the correct fix. Index: sgrepmdi.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/sgrepmdi.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sgrepmdi.py 2 Aug 2002 12:55:20 -0000 1.3 --- sgrepmdi.py 8 Jun 2004 23:25:59 -0000 1.4 *************** *** 116,120 **** #regexGrepResult=regex.compile("^\\([a-zA-Z]:.*\\)(\\([0-9]+\\))") ! regexGrepResult=re.compile("^\\([a-zA-Z]:[^(]*\\)(\\([0-9]+\\))") #these are the atom numbers defined by Windows for basic dialog controls --- 116,120 ---- #regexGrepResult=regex.compile("^\\([a-zA-Z]:.*\\)(\\([0-9]+\\))") ! regexGrep=re.compile(r"^([a-zA-Z]:[^(]*)\(([0-9]+)\)") #these are the atom numbers defined by Windows for basic dialog controls *************** *** 320,324 **** def OnLDblClick(self,params): line = self.GetLine() ! if regexGrepResult.match(line) > 0: fname = regexGrepResult.group(1) line = string.atoi(regexGrepResult.group(2)) --- 320,325 ---- def OnLDblClick(self,params): line = self.GetLine() ! regexGrepResult = regexGrep.match(line) ! if regexGrepResult: fname = regexGrepResult.group(1) line = string.atoi(regexGrepResult.group(2)) *************** *** 332,336 **** lineno = self._obj_.LineFromChar(-1) #selection or current line line = self._obj_.GetLine(lineno) ! if regexGrepResult.match(line) > 0: self.fnm = regexGrepResult.group(1) self.lnnum = string.atoi(regexGrepResult.group(2)) --- 333,338 ---- lineno = self._obj_.LineFromChar(-1) #selection or current line line = self._obj_.GetLine(lineno) ! regexGrepResult = regexGrep.match(line) ! if regexGrepResult: self.fnm = regexGrepResult.group(1) self.lnnum = string.atoi(regexGrepResult.group(2)) |
|
From: Roger U. <ru...@us...> - 2004-06-08 04:05:40
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25326/win32/src Modified Files: win32security.i Log Message: Return modified privileges from AdjustTokenPrivileges, some doc improvements Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** win32security.i 26 May 2004 02:58:33 -0000 1.16 --- win32security.i 8 Jun 2004 04:05:31 -0000 1.17 *************** *** 102,106 **** // @object PyTOKEN_PRIVILEGES|An object representing Win32 token privileges. ! // @comm This is a sequence (eg, list) of (id, attributes) %{ --- 102,109 ---- // @object PyTOKEN_PRIVILEGES|An object representing Win32 token privileges. ! // @comm This is a sequence (eg, list) of ((id, attributes),...) where id is a ! // privilege LUID as returned by <om win32security.LookupPrivilegeValue> and ! // attributes is a combination if SE_PRIVILEGE_ENABLED, SE_PRIVILEGE_ENABLED_BY_DEFAULT, ! // and SE_PRIVILEGE_USED_FOR_ACCESS %{ *************** *** 248,252 **** } ! void PyMAPIObject_FreeTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *pPriv) { free(pPriv); --- 251,255 ---- } ! void PyWinObject_FreeTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *pPriv) { free(pPriv); *************** *** 280,284 **** } %typemap(python,freearg) TOKEN_PRIVILEGES * { ! if ($source) PyMAPIObject_FreeTOKEN_PRIVILEGES($source); } --- 283,287 ---- } %typemap(python,freearg) TOKEN_PRIVILEGES * { ! if ($source) PyWinObject_FreeTOKEN_PRIVILEGES($source); } *************** *** 288,293 **** } ! %typemap(python,out) TOKEN_PRIVILEGES { ! $target = PyWinObject_FromTOKEN_PRIVILEGES($source); } --- 291,301 ---- } ! %typemap(python,out) TOKEN_PRIVILEGES *{ ! if ($source==NULL) ! $target=NULL; ! else{ ! $target = PyWinObject_FromTOKEN_PRIVILEGES($source); ! free($source); ! } } *************** *** 975,996 **** %} - %{ ! BOOL MyAdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges, TOKEN_PRIVILEGES *NewState) { ! AdjustTokenPrivileges(TokenHandle, DisableAllPrivileges, NewState, 0, NULL, 0); // Note that AdjustTokenPrivileges may succeed, and yet // some privileges weren't actually adjusted. // You've got to check GetLastError() to be sure! DWORD rc = GetLastError(); ! return rc==0 || rc==ERROR_NOT_ALL_ASSIGNED; } %} ! // @pyswig |AdjustTokenPrivileges| ! %name(AdjustTokenPrivileges) BOOLAPI MyAdjustTokenPrivileges( HANDLE TokenHandle, // @pyparm int|handle||handle to token that contains privileges BOOL DisableAllPrivileges, // @pyparm int|bDisableAllPrivileges||Flag for disabling all privileges --- 983,1024 ---- %} %{ ! TOKEN_PRIVILEGES *MyAdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges, TOKEN_PRIVILEGES *NewState) { ! DWORD origbufsize=sizeof(DWORD) + (3*sizeof(LUID_AND_ATTRIBUTES)); ! DWORD reqdbufsize=0; ! TOKEN_PRIVILEGES *PreviousState=(TOKEN_PRIVILEGES *)malloc(origbufsize); ! if (PreviousState==NULL){ ! PyErr_SetString(PyExc_MemoryError,"AdjustTokenPrivileges: unable to allocate return buffer"); ! return NULL; ! } ! ! if (!AdjustTokenPrivileges(TokenHandle, DisableAllPrivileges, NewState, origbufsize, PreviousState, &reqdbufsize)) ! if (reqdbufsize>origbufsize){ ! free(PreviousState); ! PreviousState=(TOKEN_PRIVILEGES *)malloc(reqdbufsize); ! if (PreviousState==NULL){ ! PyErr_SetString(PyExc_MemoryError,"AdjustTokenPrivileges: unable to allocate return buffer"); ! return NULL; ! } ! AdjustTokenPrivileges(TokenHandle, DisableAllPrivileges, NewState, reqdbufsize, PreviousState, &reqdbufsize); ! } // Note that AdjustTokenPrivileges may succeed, and yet // some privileges weren't actually adjusted. // You've got to check GetLastError() to be sure! DWORD rc = GetLastError(); ! if (rc==0 || rc==ERROR_NOT_ALL_ASSIGNED) ! return PreviousState; ! PyWin_SetAPIError("AdjustTokenPrivileges",rc); ! free(PreviousState); ! return NULL; } %} ! // @pyswig <o PyTOKEN_PRIVILEGES>|AdjustTokenPrivileges|Enables or disables privileges for an access token, returns modified privileges for later restoral ! %name(AdjustTokenPrivileges) TOKEN_PRIVILEGES *MyAdjustTokenPrivileges( HANDLE TokenHandle, // @pyparm int|handle||handle to token that contains privileges BOOL DisableAllPrivileges, // @pyparm int|bDisableAllPrivileges||Flag for disabling all privileges *************** *** 998,1003 **** ); - - // @pyswig <o PyTOKEN_GROUPS>|AdjustTokenGroups|Sets the groups associated to an access token,returns previous group info %native(AdjustTokenGroups) PyAdjustTokenGroups; --- 1026,1029 ---- *************** *** 1016,1026 **** &reset, // @pyparm int|ResetToDefault||Sets groups to default enabled/disabled states, &obtg)) // @pyparm PyTOKEN_GROUPS|NewState||Groups and attributes to be set for token if (!PyWinObject_AsHANDLE(obHandle, &th, FALSE)) return NULL; ! if (!PyWinObject_AsTOKEN_GROUPS(obtg, &newstate)) return NULL; DWORD bufsize = 0, origbufsize = 10; //pick a number out of a hat ! TOKEN_GROUPS *oldstate = (TOKEN_GROUPS *)malloc(origbufsize); if (oldstate==NULL) { PyErr_SetString(PyExc_MemoryError, "AdjustTokenGroups: unable to allocate memory"); --- 1042,1053 ---- &reset, // @pyparm int|ResetToDefault||Sets groups to default enabled/disabled states, &obtg)) // @pyparm PyTOKEN_GROUPS|NewState||Groups and attributes to be set for token + return NULL; if (!PyWinObject_AsHANDLE(obHandle, &th, FALSE)) return NULL; ! if (!PyWinObject_AsTOKEN_GROUPS(obtg, &newstate)) return NULL; DWORD bufsize = 0, origbufsize = 10; //pick a number out of a hat ! TOKEN_GROUPS *oldstate = (TOKEN_GROUPS *)malloc(origbufsize); if (oldstate==NULL) { PyErr_SetString(PyExc_MemoryError, "AdjustTokenGroups: unable to allocate memory"); *************** *** 1052,1057 **** %} - - // @pyswig object|GetTokenInformation|Retrieves a specified type of information about an access token. The calling process must have appropriate access rights to obtain the information. %native(GetTokenInformation) PyGetTokenInformation; --- 1079,1082 ---- *************** *** 1515,1519 **** if (!PyArg_ParseTuple(args, "Oi:LsaOpenPolicy", ! &obsystem_name, // @pyparm string/<o PyUnicode>|obsystem_name||System name, local system assumed if not specified &access_mask)) // @pyparm int|access_mask||Bitmask of requested access types return NULL; --- 1540,1544 ---- if (!PyArg_ParseTuple(args, "Oi:LsaOpenPolicy", ! &obsystem_name, // @pyparm string/<o PyUnicode>|system_name||System name, local system assumed if not specified &access_mask)) // @pyparm int|access_mask||Bitmask of requested access types return NULL; *************** *** 1539,1542 **** --- 1564,1568 ---- { PyObject *obHandle; + // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> if (!PyArg_ParseTuple(args, "O:LsaClose", &obHandle)) return NULL; *************** *** 1560,1563 **** --- 1586,1591 ---- void* buf = NULL; POLICY_INFORMATION_CLASS info_class; + // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> + // @pyparm int|InformationClass||POLICY_INFORMATION_CLASS value if (!PyArg_ParseTuple(args, "Oi:LsaQueryInformationPolicy", &obhandle, (long *)&info_class)) return NULL; *************** *** 1670,1673 **** --- 1698,1704 ---- void* buf = NULL; POLICY_INFORMATION_CLASS info_class; + // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> + // @pyparm int|InformationClass||POLICY_INFORMATION_CLASS value + // @pyparm object|Information||Type is dependent on InformationClass if (!PyArg_ParseTuple(args, "OiO:PyLsaSetInformationPolicy", &obhandle, (long *)&info_class, &obinfo)) return NULL; *************** *** 1745,1748 **** --- 1776,1782 ---- HANDLE hpolicy; NTSTATUS err; + // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> + // @pyparm <o PySID>|AccountSid||Account to which privs will be added + // @pyparm (str/unicode,...)|UserRights||List of privilege names (SE_*_NAME unicode constants) if (!PyArg_ParseTuple(args, "OOO:LsaAddAccountRights", &policy_handle, &obsid, &privs)) return NULL; *************** *** 1803,1806 **** --- 1837,1844 ---- HANDLE hpolicy; NTSTATUS err; + // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> + // @pyparm <o PySID>|AccountSid||Account whose privileges will be removed + // @pyparm int|AllRights||Boolean value indicating if all privs should be removed from account + // @pyparm (str/unicode,...)|UserRights||List of privilege names to be removed (SE_*_NAME unicode constants) if (!PyArg_ParseTuple(args, "OOiO:LsaAddAccountRights", &policy_handle, &obsid, &AllRights, &privs)) return NULL; *************** *** 1860,1864 **** HANDLE hpolicy; NTSTATUS err; ! if (!PyArg_ParseTuple(args, "OO:LsaAddAccountRights", &policy_handle, &obsid)) return NULL; if (!PyWinObject_AsHANDLE(policy_handle, &hpolicy)) --- 1898,1904 ---- HANDLE hpolicy; NTSTATUS err; ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> ! // @pyparm <o PySID>|AccountSid||Security identifier of account for which to list privs ! if (!PyArg_ParseTuple(args, "OO:LsaEnumerateAccountRights", &policy_handle, &obsid)) return NULL; if (!PyWinObject_AsHANDLE(policy_handle, &hpolicy)) *************** *** 1899,1902 **** --- 1939,1944 ---- void *buf_start; NTSTATUS err; + // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> + // @pyparm str/unicode|UserRight||Name of privilege (SE_*_NAME unicode constant) if (!PyArg_ParseTuple(args, "OO:LsaEnumerateAccountsWithUserRight", &policy_handle, &obpriv)) return NULL; *************** *** 2050,2056 **** static PyObject *PyLsaStorePrivateData(PyObject *self, PyObject *args) { ! // @pyparm <o PyHANDLE>|handle||Policy handle // @pyparm string|KeyName||Registry key in which to store data ! // @pyparm int|PrivateData||Unicode string to be encrypted and stored PyObject *obpolicyhandle=NULL, *obkeyname=NULL, *obprivatedata=NULL; PyObject * ret=NULL; --- 2092,2098 ---- static PyObject *PyLsaStorePrivateData(PyObject *self, PyObject *args) { ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm string|KeyName||Registry key in which to store data ! // @pyparm <o PyUNICODE>|PrivateData||Unicode string to be encrypted and stored PyObject *obpolicyhandle=NULL, *obkeyname=NULL, *obprivatedata=NULL; PyObject * ret=NULL; *************** *** 2095,2099 **** static PyObject *PyLsaRetrievePrivateData(PyObject *self, PyObject *args) { ! // @pyparm <o PyHANDLE>|handle||Policy handle // @pyparm string|KeyName||Registry key to read PyObject *obpolicyhandle=NULL, *obkeyname=NULL, *obprivatedata=NULL; --- 2137,2141 ---- static PyObject *PyLsaRetrievePrivateData(PyObject *self, PyObject *args) { ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm string|KeyName||Registry key to read PyObject *obpolicyhandle=NULL, *obkeyname=NULL, *obprivatedata=NULL; *************** *** 2181,2184 **** --- 2223,2227 ---- %} + // @pyswig object|CryptEnumProviders|List cryptography providers %native(CryptEnumProviders) PyCryptEnumProviders; |
|
From: Roger U. <ru...@us...> - 2004-05-26 22:50:44
|
Update of /cvsroot/pywin32/pywin32/win32/Demos/security In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12940/win32/Demos/security Added Files: setkernelobjectsecurity.py setnamedsecurityinfo.py setsecurityinfo.py setuserobjectsecurity.py Log Message: Some scripts to demonstrate usage/verify operation of object security functions --- NEW FILE: setuserobjectsecurity.py --- import win32security,win32api,win32con, win32process new_privs = ((win32security.LookupPrivilegeValue('',win32security.SE_SECURITY_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_TCB_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_SHUTDOWN_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_RESTORE_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_TAKE_OWNERSHIP_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_CREATE_PERMANENT_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_ENABLE_DELEGATION_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_CHANGE_NOTIFY_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_DEBUG_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_PROF_SINGLE_PROCESS_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_SYSTEM_PROFILE_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_LOCK_MEMORY_NAME),win32con.SE_PRIVILEGE_ENABLED) ) all_info=win32security.OWNER_SECURITY_INFORMATION|win32security.GROUP_SECURITY_INFORMATION| \ win32security.DACL_SECURITY_INFORMATION|win32security.SACL_SECURITY_INFORMATION info=win32security.OWNER_SECURITY_INFORMATION|win32security.GROUP_SECURITY_INFORMATION|win32security.DACL_SECURITY_INFORMATION ph=win32process.GetCurrentProcess() th = win32security.OpenProcessToken(ph,win32security.TOKEN_ALL_ACCESS) ##win32con.TOKEN_ADJUST_PRIVILEGES) win32security.AdjustTokenPrivileges(th,0,new_privs) my_sid = win32security.GetTokenInformation(th,win32security.TokenUser)[0] pwr_sid=win32security.LookupAccountName('','Power Users')[0] h=win32process.GetProcessWindowStation() sd=win32security.GetUserObjectSecurity(h,info) dacl=sd.GetSecurityDescriptorDacl() ace_cnt=dacl.GetAceCount() dacl.AddAccessAllowedAce(dacl.GetAclRevision(),win32con.ACCESS_SYSTEM_SECURITY|win32con.WRITE_DAC,my_sid) sd.SetSecurityDescriptorDacl(1,dacl,0) sd.SetSecurityDescriptorGroup(pwr_sid,0) sd.SetSecurityDescriptorOwner(pwr_sid,0) win32security.SetUserObjectSecurity(h,info,sd) new_sd=win32security.GetUserObjectSecurity(h,info) assert new_sd.GetSecurityDescriptorDacl().GetAceCount()==ace_cnt+1,'Did not add an ace to the Dacl !!!!!!' assert win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]=='Power Users','Owner not successfully set to Power Users !!!!!' assert win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]=='Power Users','Group not successfully set to Power Users !!!!!' --- NEW FILE: setsecurityinfo.py --- import win32security,win32api,win32con, win32process ## You need SE_RESTORE_NAME to be able to set the owner of a security descriptor to anybody ## other than yourself or your primary group. Most admin logins don't have it by default, so ## enabling it may fail new_privs = ((win32security.LookupPrivilegeValue('',win32security.SE_SECURITY_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_TCB_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_SHUTDOWN_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_RESTORE_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_TAKE_OWNERSHIP_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_CREATE_PERMANENT_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_ENABLE_DELEGATION_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_CHANGE_NOTIFY_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_DEBUG_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_PROF_SINGLE_PROCESS_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_SYSTEM_PROFILE_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_LOCK_MEMORY_NAME),win32con.SE_PRIVILEGE_ENABLED) ) all_info=win32security.OWNER_SECURITY_INFORMATION|win32security.GROUP_SECURITY_INFORMATION| \ win32security.DACL_SECURITY_INFORMATION|win32security.SACL_SECURITY_INFORMATION pid=win32api.GetCurrentProcessId() ph=win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS,0,pid) ## PROCESS_ALL_ACCESS does not contain ACCESS_SYSTEM_SECURITY (neccessy to do SACLs) th = win32security.OpenProcessToken(ph,win32security.TOKEN_ALL_ACCESS) ##win32con.TOKEN_ADJUST_PRIVILEGES) old_privs=win32security.AdjustTokenPrivileges(th,0,new_privs) my_sid = win32security.GetTokenInformation(th,win32security.TokenUser)[0] pwr_sid=win32security.LookupAccountName('','Power Users')[0] ## reopen process with ACCESS_SYSTEM_SECURITY now that sufficent privs are enabled ph=win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS|win32con.ACCESS_SYSTEM_SECURITY,0,pid) sd=win32security.GetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,all_info) dacl=sd.GetSecurityDescriptorDacl() if dacl is None: dacl=win32security.ACL() sacl=sd.GetSecurityDescriptorSacl() if sacl is None: sacl=win32security.ACL() dacl_ace_cnt=dacl.GetAceCount() sacl_ace_cnt=sacl.GetAceCount() dacl.AddAccessAllowedAce(dacl.GetAclRevision(),win32con.ACCESS_SYSTEM_SECURITY|win32con.WRITE_DAC,my_sid) sacl.AddAuditAccessAce(sacl.GetAclRevision(),win32con.GENERIC_ALL,my_sid,1,1) win32security.SetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,all_info,pwr_sid, pwr_sid, dacl, sacl) new_sd=win32security.GetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,all_info) if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1: print 'New dacl doesn''t contain extra ace ????' if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1: print 'New Sacl doesn''t contain extra ace ????' if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users': print 'Owner not successfully set to Power Users !!!!!' if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users': print 'Group not successfully set to Power Users !!!!!' win32security.SetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,win32security.SACL_SECURITY_INFORMATION, None, None, None, None) new_sd_1=win32security.GetSecurityInfo(ph,win32security.SE_KERNEL_OBJECT,win32security.SACL_SECURITY_INFORMATION) if new_sd_1.GetSecurityDescriptorSacl() is not None: print 'Unable to set Sacl to NULL !!!!!!!!' --- NEW FILE: setkernelobjectsecurity.py --- import win32security,win32api,win32con, win32process ## You need SE_RESTORE_NAME to be able to set the owner of a security descriptor to anybody ## other than yourself or your primary group. Most admin logins don't have it by default, so ## enabling it may fail new_privs = ((win32security.LookupPrivilegeValue('',win32security.SE_SECURITY_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_TCB_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_SHUTDOWN_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_RESTORE_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_TAKE_OWNERSHIP_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_CREATE_PERMANENT_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_ENABLE_DELEGATION_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_CHANGE_NOTIFY_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_DEBUG_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_PROF_SINGLE_PROCESS_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_SYSTEM_PROFILE_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_LOCK_MEMORY_NAME),win32con.SE_PRIVILEGE_ENABLED) ) all_info=win32security.OWNER_SECURITY_INFORMATION|win32security.GROUP_SECURITY_INFORMATION| \ win32security.DACL_SECURITY_INFORMATION|win32security.SACL_SECURITY_INFORMATION pid=win32api.GetCurrentProcessId() ph=win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS,0,pid) ## PROCESS_ALL_ACCESS does not contain ACCESS_SYSTEM_SECURITY (neccessy to do SACLs) th = win32security.OpenProcessToken(ph,win32security.TOKEN_ALL_ACCESS) ##win32con.TOKEN_ADJUST_PRIVILEGES) old_privs=win32security.AdjustTokenPrivileges(th,0,new_privs) my_sid = win32security.GetTokenInformation(th,win32security.TokenUser)[0] pwr_sid=win32security.LookupAccountName('','Power Users')[0] ## reopen process with ACCESS_SYSTEM_SECURITY now that sufficent privs are enabled ph=win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS|win32con.ACCESS_SYSTEM_SECURITY,0,pid) sd=win32security.GetKernelObjectSecurity(ph,all_info) dacl=sd.GetSecurityDescriptorDacl() if dacl is None: dacl=win32security.ACL() sacl=sd.GetSecurityDescriptorSacl() if sacl is None: sacl=win32security.ACL() dacl_ace_cnt=dacl.GetAceCount() sacl_ace_cnt=sacl.GetAceCount() dacl.AddAccessAllowedAce(dacl.GetAclRevision(),win32con.ACCESS_SYSTEM_SECURITY|win32con.WRITE_DAC,my_sid) sacl.AddAuditAccessAce(sacl.GetAclRevision(),win32con.GENERIC_ALL,my_sid,1,1) sd.SetSecurityDescriptorDacl(1,dacl,0) sd.SetSecurityDescriptorSacl(1,sacl,0) sd.SetSecurityDescriptorGroup(pwr_sid,0) sd.SetSecurityDescriptorOwner(pwr_sid,0) win32security.SetKernelObjectSecurity(ph,all_info,sd) new_sd=win32security.GetKernelObjectSecurity(ph,all_info) if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1: print 'New dacl doesn''t contain extra ace ????' if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1: print 'New Sacl doesn''t contain extra ace ????' if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users': print 'Owner not successfully set to Power Users !!!!!' if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users': print 'Group not successfully set to Power Users !!!!!' sd.SetSecurityDescriptorSacl(0,None,0) win32security.SetKernelObjectSecurity(ph, win32security.SACL_SECURITY_INFORMATION, sd) new_sd_1=win32security.GetKernelObjectSecurity(ph,win32security.SACL_SECURITY_INFORMATION) if new_sd_1.GetSecurityDescriptorSacl() is not None: print 'Unable to set Sacl to NULL !!!!!!!!' --- NEW FILE: setnamedsecurityinfo.py --- import win32security,win32api,win32con, win32process fname, tmp = win32api.GetTempFileName(win32api.GetTempPath(),'tmp') print fname ## You need SE_RESTORE_NAME to be able to set the owner of a security descriptor to anybody ## other than yourself or your primary group. Most admin logins don't have it by default, so ## enabling it may fail new_privs = ((win32security.LookupPrivilegeValue('',win32security.SE_SECURITY_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_TCB_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_SHUTDOWN_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_RESTORE_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_TAKE_OWNERSHIP_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_CREATE_PERMANENT_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_ENABLE_DELEGATION_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_CHANGE_NOTIFY_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_DEBUG_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_PROF_SINGLE_PROCESS_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_SYSTEM_PROFILE_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',win32security.SE_LOCK_MEMORY_NAME),win32con.SE_PRIVILEGE_ENABLED) ) all_info=win32security.OWNER_SECURITY_INFORMATION|win32security.GROUP_SECURITY_INFORMATION| \ win32security.DACL_SECURITY_INFORMATION|win32security.SACL_SECURITY_INFORMATION ph=win32process.GetCurrentProcess() th = win32security.OpenProcessToken(ph,win32security.TOKEN_ALL_ACCESS) ##win32con.TOKEN_ADJUST_PRIVILEGES) win32security.AdjustTokenPrivileges(th,0,new_privs) my_sid = win32security.GetTokenInformation(th,win32security.TokenUser)[0] pwr_sid=win32security.LookupAccountName('','Power Users')[0] sd=win32security.GetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,all_info) dacl=sd.GetSecurityDescriptorDacl() if dacl is None: dacl=win32security.ACL() sacl=sd.GetSecurityDescriptorSacl() if sacl is None: sacl=win32security.ACL() dacl_ace_cnt=dacl.GetAceCount() sacl_ace_cnt=sacl.GetAceCount() dacl.AddAccessAllowedAce(dacl.GetAclRevision(),win32con.ACCESS_SYSTEM_SECURITY|win32con.WRITE_DAC,my_sid) sacl.AddAuditAccessAce(sacl.GetAclRevision(),win32con.GENERIC_ALL,my_sid,1,1) win32security.SetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,all_info,pwr_sid, pwr_sid, dacl, sacl) new_sd=win32security.GetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,all_info) ## could do additional checking to make sure added ACE contains expected info if new_sd.GetSecurityDescriptorDacl().GetAceCount()!=dacl_ace_cnt+1: print 'New dacl doesn''t contain extra ace ????' if new_sd.GetSecurityDescriptorSacl().GetAceCount()!=sacl_ace_cnt+1: print 'New Sacl doesn''t contain extra ace ????' if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorOwner())[0]!='Power Users': print 'Owner not successfully set to Power Users !!!!!' if win32security.LookupAccountSid('',new_sd.GetSecurityDescriptorGroup())[0]!='Power Users': print 'Group not successfully set to Power Users !!!!!' win32security.SetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,win32security.SACL_SECURITY_INFORMATION, None, None, None, None) new_sd_1=win32security.GetNamedSecurityInfo(fname,win32security.SE_FILE_OBJECT,win32security.SACL_SECURITY_INFORMATION) if new_sd_1.GetSecurityDescriptorSacl() is not None: print 'Unable to set Sacl to NULL !!!!!!!!' |
|
From: Mark H. <mha...@us...> - 2004-05-26 09:42:39
|
Update of /cvsroot/pywin32/pywin32/com/win32com/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16799 Modified Files: register.py Log Message: Fix registration for frozen COM servers - don't add any additional paths to the registry, and don't register in the "Python COM Servers" category Index: register.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/server/register.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** register.py 27 Apr 2004 01:00:57 -0000 1.18 --- register.py 26 May 2004 09:42:30 -0000 1.19 *************** *** 143,148 **** policy=None, catids=[], other={}, ! # Default is to register in Python categories when not frozen ! addPyComCat=not hasattr(sys, 'frozen'), dispatcher = None, clsctx = None, --- 143,147 ---- policy=None, catids=[], other={}, ! addPyComCat=None, dispatcher = None, clsctx = None, *************** *** 164,168 **** other -- A dictionary of extra items to be registered. addPyComCat -- A flag indicating if the object should be added to the list ! of Python servers installed on the machine. dispatcher -- The dispatcher to use when creating this object. clsctx -- One of the CLSCTX_* constants. --- 163,169 ---- other -- A dictionary of extra items to be registered. addPyComCat -- A flag indicating if the object should be added to the list ! of Python servers installed on the machine. If None (the default) ! then it will be registered when running from python source, but ! not registered if running in a frozen environment. dispatcher -- The dispatcher to use when creating this object. clsctx -- One of the CLSCTX_* constants. *************** *** 255,258 **** --- 256,261 ---- _remove_key(keyNameRoot + "\\PythonCOMPath") + if addPyComCat is None: + addPyComCat = pythoncom.frozen == 0 if addPyComCat: catids = catids + [ CATID_PythonCOMServer ] *************** *** 371,375 **** clsctx = _get(cls, '_reg_clsctx_') tlb_filename = _get(cls, '_reg_typelib_filename_') ! addPyComCat = not _get(cls, '_reg_disable_pycomcat_', 0) addnPath = None if debugging: --- 374,379 ---- clsctx = _get(cls, '_reg_clsctx_') tlb_filename = _get(cls, '_reg_typelib_filename_') ! # default to being a COM category only when not frozen. ! addPyComCat = not _get(cls, '_reg_disable_pycomcat_', pythoncom.frozen!=0) addnPath = None if debugging: *************** *** 388,394 **** if spec is None: - # Always write out path - the policy may or may not need it - scriptDir = os.path.split(sys.argv[0])[0] - if not scriptDir: scriptDir = "." moduleName = cls.__module__ if moduleName == '__main__': --- 392,395 ---- *************** *** 402,406 **** spec = moduleName + "." + cls.__name__ ! addnPath = win32api.GetFullPathName(scriptDir) RegisterServer(clsid, spec, desc, progID, verProgID, defIcon, --- 403,411 ---- spec = moduleName + "." + cls.__name__ ! # Frozen apps don't need their directory on sys.path ! if not pythoncom.frozen: ! scriptDir = os.path.split(sys.argv[0])[0] ! if not scriptDir: scriptDir = "." ! addnPath = win32api.GetFullPathName(scriptDir) RegisterServer(clsid, spec, desc, progID, verProgID, defIcon, *************** *** 487,497 **** "Python COM Server") ] ) ! try: ! win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, ! 'Component Categories\\%s' % CATID_PythonCOMServer) ! except win32api.error: try: ! RegisterPyComCategory() ! except pythoncom.error: # Error with the COM category manager - oh well. ! pass --- 492,503 ---- "Python COM Server") ] ) ! if not pythoncom.frozen: try: ! win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, ! 'Component Categories\\%s' % CATID_PythonCOMServer) ! except win32api.error: ! try: ! RegisterPyComCategory() ! except pythoncom.error: # Error with the COM category manager - oh well. ! pass |
|
From: Mark H. <mha...@us...> - 2004-05-26 09:41:29
|
Update of /cvsroot/pywin32/pywin32/com/win32com/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16672 Modified Files: util.py Log Message: Add FileStream class, to make an IStream from a Python file. Index: util.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/server/util.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** util.py 24 Nov 2003 09:28:10 -0000 1.4 --- util.py 26 May 2004 09:41:18 -0000 1.5 *************** *** 189,190 **** --- 189,215 ---- pythoncom.IID_IDispatch) + class FileStream: + _public_methods_ = [ 'Read', 'Write', 'Clone', 'CopyTo', 'Seek' ] + _com_interfaces_ = [ pythoncom.IID_IStream ] + + def __init__(self, file): + self.file = file + + def Read(self, amount): + return self.file.read(amount) + + def Write(self, data): + self.file.write(data) + + def Clone(self): + return self._wrap(self.__class__(self.file)) + + def CopyTo(self, dest, cb): + dest.Write(file.read(cb)) + + def Seek(self, offset, origin): + # how convient that the 'origin' values are the same as the CRT :) + self.file.seek(offset, origin) + + def _wrap(self, ob): + return wrap(ob) |
|
From: Mark H. <mha...@us...> - 2004-05-26 09:40:32
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16471 Modified Files: testShell.py Log Message: Add FILEGROUPDESCRIPTOR tests Index: testShell.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testShell.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** testShell.py 4 May 2004 07:04:09 -0000 1.5 --- testShell.py 26 May 2004 09:40:21 -0000 1.6 *************** *** 1,5 **** --- 1,8 ---- import sys, os + import struct import unittest + import copy + import win32con import pythoncom from win32com.shell import shell *************** *** 76,79 **** --- 79,123 ---- self._rtCIDA(["\0"], [ ["\0"], ["\1"], ["\2"] ]) + class FILEGROUPDESCRIPTORTester(win32com.test.util.TestCase): + def _testRT(self, fd): + fgd_string = shell.FILEGROUPDESCRIPTORAsString([fd]) + fd2 = shell.StringAsFILEGROUPDESCRIPTOR(fgd_string)[0] + + fd = fd.copy() + fd2 = fd2.copy() + + # The returned objects *always* have dwFlags and cFileName. + if not fd.has_key('dwFlags'): + del fd2['dwFlags'] + if not fd.has_key('cFileName'): + self.assertEqual(fd2['cFileName'], '') + del fd2['cFileName'] + + self.assertEqual(fd, fd2) + + def testSimple(self): + fgd = shell.FILEGROUPDESCRIPTORAsString([]) + header = struct.pack("i", 0) + self.assertEqual(header, fgd[:len(header)]) + self._testRT(dict()) + d = dict() + fgd = shell.FILEGROUPDESCRIPTORAsString([d]) + header = struct.pack("i", 1) + self.assertEqual(header, fgd[:len(header)]) + self._testRT(d) + + def testComplex(self): + clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}") + d = dict(cFileName="foo.txt", + clsid=clsid, + sizel=(1,2), + pointl=(3,4), + dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL, + ftCreationTime=pythoncom.MakeTime(10), + ftLastAccessTime=pythoncom.MakeTime(11), + ftLastWriteTime=pythoncom.MakeTime(12), + nFileSize=sys.maxint + 1) + self._testRT(d) + class FileOperationTester(win32com.test.util.TestCase): def setUp(self): |
|
From: Mark H. <mha...@us...> - 2004-05-26 09:39:21
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16255 Modified Files: shell_view.py Log Message: ParseDisplayName takes an extra arg Index: shell_view.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/shell_view.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** shell_view.py 11 Apr 2004 04:25:36 -0000 1.5 --- shell_view.py 26 May 2004 09:39:11 -0000 1.6 *************** *** 124,128 **** #print "GetFrameOptions", self, mask return 0 ! def ParseDisplayName(self, hwnd, reserved, displayName): print "ParseDisplayName", displayName # return cchEaten, pidl, attr --- 124,128 ---- #print "GetFrameOptions", self, mask return 0 ! def ParseDisplayName(self, hwnd, reserved, displayName, attr): print "ParseDisplayName", displayName # return cchEaten, pidl, attr |
|
From: Mark H. <mha...@us...> - 2004-05-26 09:37:19
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15960 Modified Files: PyIShellFolder.cpp Log Message: Oops - it was this checkin with the ParseDisplayName change! Index: PyIShellFolder.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellFolder.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyIShellFolder.cpp 9 Apr 2004 11:20:06 -0000 1.6 --- PyIShellFolder.cpp 26 May 2004 09:37:10 -0000 1.7 *************** *** 28,31 **** --- 28,34 ---- // @pymethod |PyIShellFolder|ParseDisplayName|Description of ParseDisplayName. + // @rdesc The result is a tuple of cchEaten, pidl, attr. + // cchEaten will have been initialized to -1, and may or may not be changed + // for the return value. PyObject *PyIShellFolder::ParseDisplayName(PyObject *self, PyObject *args) { *************** *** 41,48 **** IBindCtx * pbcReserved; LPOLESTR lpszDisplayName; ! ULONG pchEaten; ITEMIDLIST *ppidl; ! ULONG pdwAttributes; ! if ( !PyArg_ParseTuple(args, "lOO:ParseDisplayName", &hwndOwner, &obpbcReserved, &oblpszDisplayName) ) return NULL; BOOL bPythonIsHappy = TRUE; --- 44,52 ---- IBindCtx * pbcReserved; LPOLESTR lpszDisplayName; ! ULONG pchEaten = (ULONG)-1; ITEMIDLIST *ppidl; ! ULONG pdwAttributes = -1; ! if ( !PyArg_ParseTuple(args, "lOO|l:ParseDisplayName", &hwndOwner, &obpbcReserved, ! &oblpszDisplayName, &pdwAttributes) ) return NULL; BOOL bPythonIsHappy = TRUE; *************** *** 53,57 **** HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pISF->ParseDisplayName( hwndOwner, pbcReserved, lpszDisplayName, &pchEaten, &ppidl, &pdwAttributes ); if (pbcReserved) pbcReserved->Release(); SysFreeString(lpszDisplayName); --- 57,62 ---- HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pISF->ParseDisplayName(hwndOwner, pbcReserved, lpszDisplayName, &pchEaten, ! &ppidl, &pdwAttributes ); if (pbcReserved) pbcReserved->Release(); SysFreeString(lpszDisplayName); *************** *** 424,428 **** oblpszDisplayName = MakeOLECHARToObj(lpszDisplayName); PyObject *result; ! HRESULT hr=InvokeViaPolicy("ParseDisplayName", &result, "lOO", hwndOwner, obpbcReserved, oblpszDisplayName); Py_XDECREF(obpbcReserved); Py_XDECREF(oblpszDisplayName); --- 429,435 ---- oblpszDisplayName = MakeOLECHARToObj(lpszDisplayName); PyObject *result; ! HRESULT hr=InvokeViaPolicy("ParseDisplayName", &result, "lOOl", hwndOwner, ! obpbcReserved, ! oblpszDisplayName, pdwAttributes ? *pdwAttributes : 0); Py_XDECREF(obpbcReserved); Py_XDECREF(oblpszDisplayName); |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:57:26
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9833 Modified Files: PyIShellBrowser.cpp Log Message: IShellFolder.ParseDisplayName now takes an extra param - this may break some servers (but the old code did not provide a critical param, so could not work correctly Index: PyIShellBrowser.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellBrowser.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIShellBrowser.cpp 9 Apr 2004 11:15:10 -0000 1.3 --- PyIShellBrowser.cpp 26 May 2004 08:57:02 -0000 1.4 *************** *** 12,15 **** --- 12,18 ---- PyObject *PyObject_FromOLEMENUGROUPWIDTHS(OLEMENUGROUPWIDTHS *p); + extern BOOL PyObject_AsTBBUTTONs( PyObject *ob, TBBUTTON **ppButtons, UINT *nButtons ); + extern void PyObject_FreeTBBUTTONs(TBBUTTON *); + // Interface Implementation *************** *** 264,267 **** --- 267,301 ---- } + // Little helper stolen from win32gui + static BOOL make_param(PyObject *ob, long *pl) + { + long &l = *pl; + if (ob==NULL || ob==Py_None) + l = 0; + else + #ifdef UNICODE + #define TCHAR_DESC "Unicode" + if (PyUnicode_Check(ob)) + l = (long)PyUnicode_AsUnicode(ob); + #else + #define TCHAR_DESC "String" + if (PyString_Check(ob)) + l = (long)PyString_AsString(ob); + #endif + else if (PyInt_Check(ob)) + l = PyInt_AsLong(ob); + else { + PyBufferProcs *pb = ob->ob_type->tp_as_buffer; + if (pb != NULL && pb->bf_getreadbuffer) { + if(-1 == pb->bf_getreadbuffer(ob,0,(void **) &l)) + return FALSE; + } else { + PyErr_SetString(PyExc_TypeError, "Must be a" TCHAR_DESC ", int, or buffer object"); + return FALSE; + } + } + return TRUE; + } + // @pymethod |PyIShellBrowser|SendControlMsg|Description of SendControlMsg. PyObject *PyIShellBrowser::SendControlMsg(PyObject *self, PyObject *args) *************** *** 276,283 **** UINT id; UINT uMsg; WPARAM wParam; LPARAM lParam; ! if ( !PyArg_ParseTuple(args, "iiil:SendControlMsg", &id, &uMsg, &wParam, &lParam) ) return NULL; HRESULT hr; LRESULT ret; --- 310,323 ---- UINT id; UINT uMsg; + PyObject *obwparam, *oblparam; + if ( !PyArg_ParseTuple(args, "iiOO:SendControlMsg", &id, &uMsg, &obwparam, &oblparam) ) + return NULL; WPARAM wParam; LPARAM lParam; ! if (!make_param(obwparam, (long *)&wParam)) return NULL; + if (!make_param(oblparam, (long *)&lParam)) + return NULL; + HRESULT hr; LRESULT ret; *************** *** 335,339 **** } - /* // @pymethod |PyIShellBrowser|SetToolbarItems|Description of SetToolbarItems. PyObject *PyIShellBrowser::SetToolbarItems(PyObject *self, PyObject *args) --- 375,378 ---- *************** *** 342,364 **** if ( pISB == NULL ) return NULL; - // *** The input argument lpButtons of type "LPTBBUTTONSB" was not processed *** - // Please check the conversion function is appropriate and exists! LPTBBUTTONSB lpButtons; PyObject *oblpButtons; // @pyparm <o PyLPTBBUTTONSB>|lpButtons||Description for lpButtons - // @pyparm int|nButtons||Description for nButtons // @pyparm int|uFlags||Description for uFlags UINT nButtons; UINT uFlags; ! if ( !PyArg_ParseTuple(args, "Oii:SetToolbarItems", &oblpButtons, &nButtons, &uFlags) ) return NULL; BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyObject_AsLPTBBUTTONSB( oblpButtons, &lpButtons )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->SetToolbarItems( lpButtons, nButtons, uFlags ); ! PyObject_FreeLPTBBUTTONSB(lpButtons); ! PY_INTERFACE_POSTCALL; --- 381,399 ---- if ( pISB == NULL ) return NULL; LPTBBUTTONSB lpButtons; PyObject *oblpButtons; // @pyparm <o PyLPTBBUTTONSB>|lpButtons||Description for lpButtons // @pyparm int|uFlags||Description for uFlags UINT nButtons; UINT uFlags; ! if ( !PyArg_ParseTuple(args, "Oi:SetToolbarItems", &oblpButtons, &uFlags) ) return NULL; BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyObject_AsTBBUTTONs( oblpButtons, &lpButtons, &nButtons )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->SetToolbarItems( lpButtons, nButtons, uFlags ); ! PyObject_FreeTBBUTTONs(lpButtons); PY_INTERFACE_POSTCALL; *************** *** 369,374 **** } ! */ ! // @object PyIShellBrowser|Description of the interface static struct PyMethodDef PyIShellBrowser_methods[] = { --- 404,408 ---- } ! static struct PyMethodDef PyIShellBrowser_methods[] = { *************** *** 385,388 **** --- 419,423 ---- { "QueryActiveShellView", PyIShellBrowser::QueryActiveShellView, 1 }, // @pymeth QueryActiveShellView|Description of QueryActiveShellView { "OnViewWindowActive", PyIShellBrowser::OnViewWindowActive, 1 }, // @pymeth OnViewWindowActive|Description of OnViewWindowActive + { "SetToolbarItems", PyIShellBrowser::SetToolbarItems, 1}, // @pymeth SetToolbarItems|Description of OnViewWindowActive { NULL } }; |