pywin32-checkins Mailing List for Python for Windows Extensions (Page 95)
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: Roger U. <ru...@us...> - 2007-02-08 09:53:26
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29588 Modified Files: win32con.py Log Message: Add flags for SetSystemFileCacheSize Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** win32con.py 5 Feb 2007 01:46:40 -0000 1.18 --- win32con.py 8 Feb 2007 09:53:23 -0000 1.19 *************** *** 4929,4930 **** --- 4929,4936 ---- GRADIENT_FILL_TRIANGLE = 2 GRADIENT_FILL_OP_FLAG = 255 + + ## flags used with Get/SetSystemFileCacheSize + MM_WORKING_SET_MAX_HARD_ENABLE = 1 + MM_WORKING_SET_MAX_HARD_DISABLE = 2 + MM_WORKING_SET_MIN_HARD_ENABLE = 4 + MM_WORKING_SET_MIN_HARD_DISABLE = 8 |
From: Roger U. <ru...@us...> - 2007-02-08 07:19:59
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2156 Modified Files: win32file.i Log Message: Add FindStreams Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** win32file.i 7 Feb 2007 03:35:35 -0000 1.71 --- win32file.i 8 Feb 2007 07:19:57 -0000 1.72 *************** *** 2721,2725 **** static FindFirstFileTransactedfunc pfnFindFirstFileTransacted=NULL; - // These aren't used yet typedef HANDLE (WINAPI *FindFirstStreamfunc)(LPWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD); static FindFirstStreamfunc pfnFindFirstStream=NULL; --- 2721,2724 ---- *************** *** 2728,2731 **** --- 2727,2732 ---- typedef HANDLE (WINAPI *FindFirstStreamTransactedfunc)(LPWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD, HANDLE); static FindFirstStreamTransactedfunc pfnFindFirstStreamTransacted=NULL; + + // These aren't used yet typedef DWORD (WINAPI *GetFullPathNameTransactedfunc)(LPCTSTR,DWORD,LPTSTR,LPTSTR*,HANDLE); static GetFullPathNameTransactedfunc pfnGetFullPathNameTransacted = NULL; *************** *** 4613,4616 **** --- 4614,4680 ---- } PyCFunction pfnpy_FindFilesIterator=(PyCFunction)py_FindFilesIterator; + + // @pyswig [(long, <o PyUnicode>),...]|FindStreams|List the data streams for a file + // @rdesc Returns a list of tuples containing each stream's size and name + // @comm This uses the API functions FindFirstStreamW, FindNextStreamW and FindClose + // @comm Available on Windows Server 2003 and Vista + // @comm If the Transaction arg is not None, FindFirstStreamTransacted will be called in place of FindFirstStreamW + static PyObject *py_FindStreams(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(FindFirstStream); + CHECK_PFN(FindNextStream); + + PyObject *obfname, *obtrans=Py_None, *ret=NULL, *ret_item; + WCHAR *fname=NULL; + HANDLE hfind, htrans; + STREAM_INFO_LEVELS lvl = FindStreamInfoStandard; // only level that currently exists + WIN32_FIND_STREAM_DATA fsd; + DWORD err=0, flags=0, ret_cnt=0; // flags are reserved, don't even accept as input + static char *keywords[]={"FileName","Transaction", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:FindStreams", keywords, + &obfname, // @pyparm <o PyUnicode>|FileName||Name of file (or directory) to operate on + &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction, can be None + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, TRUE)) + return NULL; + if (htrans!=NULL) + CHECK_PFN(FindFirstStreamTransacted); + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + + if (htrans!=NULL) + hfind=(*pfnFindFirstStreamTransacted)(fname, lvl, &fsd, flags, htrans); + else + hfind=(*pfnFindFirstStream)(fname, lvl, &fsd, flags); + PyWinObject_FreeWCHAR(fname); + if (hfind==INVALID_HANDLE_VALUE) + return PyWin_SetAPIError("FindFirstStreamW"); + ret=PyList_New(0); + if (ret!=NULL){ + while (1){ + ret_item=Py_BuildValue("Lu", fsd.StreamSize, fsd.cStreamName); + if ((ret_item==NULL) || (PyList_Append(ret, ret_item)==-1)){ + Py_XDECREF(ret_item); + Py_DECREF(ret); + ret=NULL; + break; + } + Py_DECREF(ret_item); + if (!(*pfnFindNextStream)(hfind, &fsd)){ + err=GetLastError(); + if (err!=ERROR_HANDLE_EOF){ + Py_DECREF(ret); + ret=NULL; + PyWin_SetAPIError("FindNextStream",err); + } + break; + } + } + } + FindClose(hfind); + return ret; + } + PyCFunction pfnpy_FindStreams=(PyCFunction)py_FindStreams; %} *************** *** 4654,4657 **** --- 4718,4723 ---- %native (FindFilesW) pfnpy_FindFilesW; %native (FindFilesIterator) pfnpy_FindFilesIterator; + %native (FindStreams) pfnpy_FindStreams; + %init %{ *************** *** 4676,4681 **** ||(strcmp(pmd->ml_name, "FindFilesW")==0) ||(strcmp(pmd->ml_name, "FindFilesIterator")==0) ! ||(strcmp(pmd->ml_name, "FindFirstStream")==0) // not impl yet ! ||(strcmp(pmd->ml_name, "FindFirstStreamTransacted")==0) // not impl yet ||(strcmp(pmd->ml_name, "GetFullPathNameTransacted")==0) // not impl yet ||(strcmp(pmd->ml_name, "GetLongPathNameTransacted")==0) // not impl yet --- 4742,4746 ---- ||(strcmp(pmd->ml_name, "FindFilesW")==0) ||(strcmp(pmd->ml_name, "FindFilesIterator")==0) ! ||(strcmp(pmd->ml_name, "FindStreams")==0) ||(strcmp(pmd->ml_name, "GetFullPathNameTransacted")==0) // not impl yet ||(strcmp(pmd->ml_name, "GetLongPathNameTransacted")==0) // not impl yet *************** *** 4758,4766 **** pfnCreateDirectoryTransacted=(CreateDirectoryTransactedfunc)GetProcAddress(hmodule, "CreateDirectoryTransactedW"); pfnRemoveDirectoryTransacted=(RemoveDirectoryTransactedfunc)GetProcAddress(hmodule, "RemoveDirectoryTransactedW"); - // these aren't wrapped yet pfnFindFirstStream=(FindFirstStreamfunc)GetProcAddress(hmodule, "FindFirstStreamW"); pfnFindNextStream=(FindNextStreamfunc)GetProcAddress(hmodule, "FindNextStreamW"); pfnFindFirstStreamTransacted=(FindFirstStreamTransactedfunc)GetProcAddress(hmodule, "FindFirstStreamTransactedW"); pfnFindFirstFileTransacted=(FindFirstFileTransactedfunc)GetProcAddress(hmodule, "FindFirstFileTransactedW"); pfnGetFullPathNameTransacted=(GetFullPathNameTransactedfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedW"); pfnGetLongPathNameTransacted=(GetLongPathNameTransactedfunc)GetProcAddress(hmodule, "GetLongPathNameTransactedW"); --- 4823,4831 ---- pfnCreateDirectoryTransacted=(CreateDirectoryTransactedfunc)GetProcAddress(hmodule, "CreateDirectoryTransactedW"); pfnRemoveDirectoryTransacted=(RemoveDirectoryTransactedfunc)GetProcAddress(hmodule, "RemoveDirectoryTransactedW"); pfnFindFirstStream=(FindFirstStreamfunc)GetProcAddress(hmodule, "FindFirstStreamW"); pfnFindNextStream=(FindNextStreamfunc)GetProcAddress(hmodule, "FindNextStreamW"); pfnFindFirstStreamTransacted=(FindFirstStreamTransactedfunc)GetProcAddress(hmodule, "FindFirstStreamTransactedW"); pfnFindFirstFileTransacted=(FindFirstFileTransactedfunc)GetProcAddress(hmodule, "FindFirstFileTransactedW"); + // these aren't wrapped yet pfnGetFullPathNameTransacted=(GetFullPathNameTransactedfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedW"); pfnGetLongPathNameTransacted=(GetLongPathNameTransactedfunc)GetProcAddress(hmodule, "GetLongPathNameTransactedW"); |
From: Mark H. <mha...@us...> - 2007-02-07 23:12:40
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12983/win32com/client Modified Files: genpy.py Log Message: Fix issue [ 1651025 ] Use the specified type for constant values This makes constants in a typelib > sys.maxint to correctly be a long Index: genpy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** genpy.py 14 Mar 2006 12:12:43 -0000 1.50 --- genpy.py 7 Feb 2007 23:12:31 -0000 1.51 *************** *** 206,210 **** if vdesc[4] == pythoncom.VAR_CONST: val = vdesc[1] ! if type(val)==type(0): if val==0x80000000L: # special case use = "0x80000000L" # 'L' for future warning --- 206,210 ---- if vdesc[4] == pythoncom.VAR_CONST: val = vdesc[1] ! if type(val) in (type(0), type(0L)): if val==0x80000000L: # special case use = "0x80000000L" # 'L' for future warning |
From: Mark H. <mha...@us...> - 2007-02-07 23:12:39
|
Update of /cvsroot/pywin32/pywin32/com/win32com/servers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12983/win32com/servers Modified Files: test_pycomtest.py Log Message: Fix issue [ 1651025 ] Use the specified type for constant values This makes constants in a typelib > sys.maxint to correctly be a long Index: test_pycomtest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/servers/test_pycomtest.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_pycomtest.py 13 Feb 2006 01:23:48 -0000 1.11 --- test_pycomtest.py 7 Feb 2007 23:12:31 -0000 1.12 *************** *** 118,121 **** --- 118,124 ---- return -1 + def Test6(self, inval): + return inval + def TestOptionals(self, strArg='def', sval=0, lval=1, dval=3.1400001049041748): raise COMException(hresult=winerror.E_NOTIMPL) |
From: Mark H. <mha...@us...> - 2007-02-07 23:12:38
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12983/win32com/src Modified Files: oleargs.cpp Log Message: Fix issue [ 1651025 ] Use the specified type for constant values This makes constants in a typelib > sys.maxint to correctly be a long Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** oleargs.cpp 21 Jun 2006 12:18:51 -0000 1.36 --- oleargs.cpp 7 Feb 2007 23:12:31 -0000 1.37 *************** *** 261,264 **** --- 261,265 ---- case VT_UI2: case VT_UI4: + case VT_UINT: hr = VariantChangeType(&varValue, &varValue, 0, VT_UI4); if ( FAILED(hr) ) *************** *** 271,275 **** // The result may be too large for a simple "long". If so, // we must return a long. ! if (V_UI4(&varValue) <= LONG_MAX) result = PyInt_FromLong(V_UI4(&varValue)); else --- 272,276 ---- // The result may be too large for a simple "long". If so, // we must return a long. ! if (V_UI4(&varValue) <= (unsigned)PyInt_GetMax()) result = PyInt_FromLong(V_UI4(&varValue)); else *************** *** 281,285 **** case VT_I4: case VT_INT: - case VT_UINT: hr = VariantChangeType(&varValue, &varValue, 0, VT_I4); if ( FAILED(hr) ) --- 282,285 ---- |
From: Mark H. <mha...@us...> - 2007-02-07 23:12:35
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12983/win32com/src/extensions Modified Files: PyVARDESC.cpp Log Message: Fix issue [ 1651025 ] Use the specified type for constant values This makes constants in a typelib > sys.maxint to correctly be a long Index: PyVARDESC.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyVARDESC.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyVARDESC.cpp 1 Sep 1999 23:03:33 -0000 1.1 --- PyVARDESC.cpp 7 Feb 2007 23:12:31 -0000 1.2 *************** *** 144,150 **** if (pVD->varkind == VAR_PERINSTANCE) value = PyInt_FromLong(pVD->oInst); ! else if (pVD->varkind == VAR_CONST) ! value = PyCom_PyObjectFromVariant(pVD->lpvarValue); ! else { value = Py_None; Py_INCREF(Py_None); --- 144,162 ---- if (pVD->varkind == VAR_PERINSTANCE) value = PyInt_FromLong(pVD->oInst); ! else if (pVD->varkind == VAR_CONST) { ! VARIANT varValue; ! ! // Cast the variant type here to the correct value for this constant ! // so that the correct Python type will be created below. ! // ! // I am not sure why is there a difference between the variant data ! // passed in from the type library and the exported type... ! VariantInit(&varValue); ! VariantChangeType(&varValue, pVD->lpvarValue, 0, pVD->elemdescVar.tdesc.vt); ! ! value = PyCom_PyObjectFromVariant(&varValue); ! ! VariantClear(&varValue); ! } else { value = Py_None; Py_INCREF(Py_None); |
From: Mark H. <mha...@us...> - 2007-02-07 23:12:34
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12983/win32com/test Modified Files: testPyComTest.py Log Message: Fix issue [ 1651025 ] Use the specified type for constant values This makes constants in a typelib > sys.maxint to correctly be a long Index: testPyComTest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testPyComTest.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** testPyComTest.py 26 Aug 2006 08:23:37 -0000 1.25 --- testPyComTest.py 7 Feb 2007 23:12:31 -0000 1.26 *************** *** 50,53 **** --- 50,61 ---- raise error, "%s failed - result not %r but %r" % (pref, result, rc) + def TestConstant(constName, pyConst): + try: + comConst = getattr(constants, constName) + except: + raise error, "Constant %s missing" % (constName,) + if comConst != pyConst: + raise error, "Constant value wrong for %s - got %d, wanted %d" % (constName, comConst, pyConst) + # Simple handler class. This demo only fires one event. class RandomEventHandler: *************** *** 234,237 **** --- 242,258 ---- TestApplyResult(o.Test5, (constants.Attr2,), constants.Attr2) + TestApplyResult(o.Test6, (constants.WideAttr1,), constants.WideAttr1) + TestApplyResult(o.Test6, (constants.WideAttr2,), constants.WideAttr2) + TestApplyResult(o.Test6, (constants.WideAttr3,), constants.WideAttr3) + TestApplyResult(o.Test6, (constants.WideAttr4,), constants.WideAttr4) + TestApplyResult(o.Test6, (constants.WideAttr5,), constants.WideAttr5) + + TestConstant("ULongTest1", 0xFFFFFFFFL) + TestConstant("ULongTest2", 0x7FFFFFFFL) + TestConstant("LongTest1", -0x7FFFFFFFL) + TestConstant("LongTest2", 0x7FFFFFFFL) + TestConstant("UCharTest", 255) + TestConstant("CharTest", -1) + now = pythoncom.MakeTime(time.gmtime(time.time())) later = pythoncom.MakeTime(time.gmtime(time.time()+1)) |
From: Mark H. <mha...@us...> - 2007-02-07 23:12:34
|
Update of /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12983/TestSources/PyCOMTest Modified Files: PyCOMImpl.cpp PyCOMImpl.h PyCOMTest.idl Log Message: Fix issue [ 1651025 ] Use the specified type for constant values This makes constants in a typelib > sys.maxint to correctly be a long Index: PyCOMTest.idl =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMTest.idl,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PyCOMTest.idl 22 Mar 2006 09:20:13 -0000 1.13 --- PyCOMTest.idl 7 Feb 2007 23:12:30 -0000 1.14 *************** *** 53,56 **** --- 53,75 ---- } QsAttribute; + // v1_enum specifies a 32 bit enum value + typedef [public, v1_enum] enum tagQsAttributeWide { + WideAttr1 = 0, + WideAttr2 = -1, + WideAttr3 = 1, + WideAttr4 = -70000, + WideAttr5 = 70000 + } QsAttributeWide; + + // constant test values + module Constants { + const unsigned long ULongTest1 = 0xFFFFFFFFUL; + const unsigned long ULongTest2 = 0x7FFFFFFFUL; + const long LongTest1 = -0x7FFFFFFFL; + const long LongTest2 = 0x7FFFFFFFL; + const unsigned char UCharTest = 255; + const char CharTest = -1; + }; + enum TestAttributes3{ // Note missing the enum name. TestAttr3, *************** *** 169,172 **** --- 188,192 ---- HRESULT Test4([in] TestAttributes2 inval, [out, retval] TestAttributes2* retval); HRESULT Test5([in, out] TestAttributes1 *inout); + HRESULT Test6([in] QsAttributeWide inval, [out, retval] QsAttributeWide* retval); // Test IDispatch in and byref. *************** *** 337,341 **** [default] interface IArrayTest; }; ! }; --- 357,361 ---- [default] interface IArrayTest; }; ! }; Index: PyCOMImpl.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMImpl.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyCOMImpl.h 22 Mar 2006 09:20:13 -0000 1.12 --- PyCOMImpl.h 7 Feb 2007 23:12:30 -0000 1.13 *************** *** 59,62 **** --- 59,63 ---- STDMETHOD(Test4)(TestAttributes2, TestAttributes2 *); STDMETHOD(Test5)(TestAttributes1 *); + STDMETHOD(Test6)(QsAttributeWide, QsAttributeWide *); STDMETHOD(GetSetInterface)(IPyCOMTest *ininterface, IPyCOMTest **outinterface); STDMETHOD(GetSetInterfaceArray)(SAFEARRAY *pin, SAFEARRAY **pout); Index: PyCOMImpl.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMImpl.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PyCOMImpl.cpp 22 Mar 2006 09:20:13 -0000 1.13 --- PyCOMImpl.cpp 7 Feb 2007 23:12:30 -0000 1.14 *************** *** 75,79 **** HRESULT hRes = S_OK; m_cs.Lock(); ! for (long i=0;i<nMaxSessions;i++) { if (m_rsArray[i].m_hEvent == NULL) --- 75,80 ---- HRESULT hRes = S_OK; m_cs.Lock(); ! long i=0; ! for (;i<nMaxSessions;i++) { if (m_rsArray[i].m_hEvent == NULL) *************** *** 155,158 **** --- 156,164 ---- return S_OK; } + STDMETHODIMP CPyCOMTest::Test6(QsAttributeWide in, QsAttributeWide *out) + { + *out = in; + return S_OK; + } STDMETHODIMP CPyCOMTest::GetSetInterface(IPyCOMTest *ininterface, IPyCOMTest **outinterface) *************** *** 473,476 **** --- 479,507 ---- CHECK_TRUE( attr == ret_attr ); + // TEST6 + QsAttributeWide ret_wideAttr; + QsAttributeWide wideAttr; + + wideAttr = WideAttr1; + CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); + CHECK_TRUE( wideAttr == ret_wideAttr ); + + wideAttr = WideAttr2; + CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); + CHECK_TRUE( wideAttr == ret_wideAttr ); + + wideAttr = WideAttr3; + CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); + CHECK_TRUE( wideAttr == ret_wideAttr ); + + wideAttr = WideAttr4; + CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); + CHECK_TRUE( wideAttr == ret_wideAttr ); + + wideAttr = WideAttr5; + CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); + CHECK_TRUE( wideAttr == ret_wideAttr ); + + // TEST5 TestAttributes1 tattr = TestAttr1; |
From: Mark H. <mha...@us...> - 2007-02-07 03:45:07
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10585/com/win32com/src Modified Files: PyComHelpers.cpp Log Message: Include the name of the type that caused a ValueError getting a COM object Index: PyComHelpers.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyComHelpers.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyComHelpers.cpp 23 Oct 2005 11:33:52 -0000 1.10 --- PyComHelpers.cpp 7 Feb 2007 03:45:05 -0000 1.11 *************** *** 252,256 **** if ( !PyIBase::is_object(ob, &PyIUnknown::type) ) { ! PyErr_SetString(PyExc_ValueError, "argument is not a COM object"); return FALSE; } --- 252,258 ---- if ( !PyIBase::is_object(ob, &PyIUnknown::type) ) { ! PyErr_Format(PyExc_ValueError, ! "argument is not a COM object (got type=%s)", ! ob->ob_type->tp_name); return FALSE; } |
From: Roger U. <ru...@us...> - 2007-02-07 03:36:01
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6724 Modified Files: win32file.i Log Message: Add optional parameter to FindFilesW and FindFilesIterator to perform a transacted search, and accept keyword args for both. Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** win32file.i 3 Feb 2007 22:33:32 -0000 1.70 --- win32file.i 7 Feb 2007 03:35:35 -0000 1.71 *************** *** 5,9 **** %{ - //#define UNICODE #ifndef MS_WINCE --- 5,8 ---- *************** *** 371,378 **** ); - //FindFirstFile - //FindFirstFileEx - // FindNextFile - // @pyswig int|FindNextChangeNotification|Requests that the operating system signal a change notification handle the next time it detects an appropriate change, BOOLAPI FindNextChangeNotification( --- 370,373 ---- *************** *** 382,442 **** #endif // MS_WINCE - %{ - // @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 * - PyFindFilesW(PyObject *self, PyObject *args) - { - WCHAR *fileSpec; - // @pyparm string|fileSpec||A string that specifies a valid directory or path and filename, which can contain wildcard characters (* and ?). - PyObject *obfileSpec=NULL; - if (!PyArg_ParseTuple (args, "O:FindFilesW", &obfileSpec)) - return NULL; - if (!PyWinObject_AsWCHAR(obfileSpec,&fileSpec,FALSE)) - return NULL; - WIN32_FIND_DATAW findData; - // @pyseeapi FindFirstFile - HANDLE hFind; - - memset(&findData, 0, sizeof(findData)); - hFind = ::FindFirstFileW(fileSpec, &findData); - PyWinObject_FreeWCHAR(fileSpec); - if (hFind==INVALID_HANDLE_VALUE) { - if (::GetLastError()==ERROR_FILE_NOT_FOUND) { // this is OK - return PyList_New(0); - } - return PyWin_SetAPIError("FindFirstFileW"); - } - PyObject *retList = PyList_New(0); - if (!retList) { - ::FindClose(hFind); - return NULL; - } - // @rdesc The return value is a list of <o WIN32_FIND_DATA> tuples. - BOOL ok = TRUE; - while (ok) { - PyObject *newItem = PyObject_FromWIN32_FIND_DATAW(&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); - } - ok = (GetLastError()==ERROR_NO_MORE_FILES); - // @pyseeapi FindClose - ::FindClose(hFind); - if (!ok) { - Py_DECREF(retList); - return PyWin_SetAPIError("FindNextFileW"); - } - return retList; - } - %} - - %native(FindFilesW) PyFindFilesW; %{ --- 377,380 ---- *************** *** 526,576 **** #endif // PY_VERSION }; - - // @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("FindFirstFileW"); - } - it->empty = TRUE; - } - return (PyObject *)it; - // @rdesc The result is a Python iterator, with each next() method - // returning a <o WIN32_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( --- 464,469 ---- *************** *** 2825,2828 **** --- 2718,2723 ---- typedef BOOL (WINAPI *RemoveDirectoryTransactedfunc)(LPWSTR,HANDLE); static RemoveDirectoryTransactedfunc pfnRemoveDirectoryTransacted=NULL; + typedef HANDLE (WINAPI *FindFirstFileTransactedfunc)(LPWSTR,FINDEX_INFO_LEVELS,LPVOID,FINDEX_SEARCH_OPS,LPVOID,DWORD,HANDLE); + static FindFirstFileTransactedfunc pfnFindFirstFileTransacted=NULL; // These aren't used yet *************** *** 2833,2838 **** typedef HANDLE (WINAPI *FindFirstStreamTransactedfunc)(LPWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD, HANDLE); static FindFirstStreamTransactedfunc pfnFindFirstStreamTransacted=NULL; - typedef HANDLE (WINAPI *FindFirstFileTransactedfunc)(LPWSTR,FINDEX_INFO_LEVELS,LPVOID,FINDEX_SEARCH_OPS,LPVOID,DWORD,HANDLE); - static FindFirstFileTransactedfunc pfnFindFirstFileTransacted=NULL; typedef DWORD (WINAPI *GetFullPathNameTransactedfunc)(LPCTSTR,DWORD,LPTSTR,LPTSTR*,HANDLE); static GetFullPathNameTransactedfunc pfnGetFullPathNameTransacted = NULL; --- 2728,2731 ---- *************** *** 4594,4599 **** } PyCFunction pfnpy_RemoveDirectoryTransacted=(PyCFunction)py_RemoveDirectoryTransacted; - %} %native (SetVolumeMountPoint) py_SetVolumeMountPoint; --- 4487,4617 ---- } PyCFunction pfnpy_RemoveDirectoryTransacted=(PyCFunction)py_RemoveDirectoryTransacted; + // @pyswig list|FindFilesW|Retrieves a list of matching filenames, using the Windows Unicode API. An interface to the API FindFirstFileW/FindNextFileW/Find close functions. + // @comm Accepts keyword args. + // @comm FindFirstFileTransacted will be called if a transaction handle is passed in. + static PyObject *py_FindFilesW(PyObject *self, PyObject *args, PyObject *kwargs) + { + WCHAR *fileSpec; + HANDLE htrans; + PyObject *obfileSpec, *obtrans=Py_None; + static char *keywords[]={"FileName","Transaction", NULL}; + + if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O|O:FindFilesW", keywords, + &obfileSpec, // @pyparm string|FileName||A string that specifies a valid directory or path and filename, which can contain wildcard characters (* and ?). + &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Transaction handle as returned by <om win32transaction.CreateTransaction>. Can be None. + // If this parameter is not None, FindFirstFileTransacted will be called to perform a transacted search + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, TRUE)) + return NULL; + if (htrans!=NULL) + CHECK_PFN(FindFirstFileTransacted); + if (!PyWinObject_AsWCHAR(obfileSpec,&fileSpec,FALSE)) + return NULL; + WIN32_FIND_DATAW findData; + // @pyseeapi FindFirstFile + // @pyseeapi FindFirstFileTransacted + HANDLE hFind; + + memset(&findData, 0, sizeof(findData)); + if (htrans!=NULL) + hFind=(*pfnFindFirstFileTransacted)(fileSpec, FindExInfoStandard, &findData, + FindExSearchNameMatch, NULL, 0, htrans); + else + hFind = ::FindFirstFileW(fileSpec, &findData); + PyWinObject_FreeWCHAR(fileSpec); + if (hFind==INVALID_HANDLE_VALUE) { + if (::GetLastError()==ERROR_FILE_NOT_FOUND) { // this is OK + return PyList_New(0); + } + return PyWin_SetAPIError("FindFirstFileW"); + } + PyObject *retList = PyList_New(0); + if (!retList) { + ::FindClose(hFind); + return NULL; + } + // @rdesc The return value is a list of <o WIN32_FIND_DATA> tuples. + BOOL ok = TRUE; + while (ok) { + PyObject *newItem = PyObject_FromWIN32_FIND_DATAW(&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); + } + ok = (GetLastError()==ERROR_NO_MORE_FILES); + // @pyseeapi FindClose + ::FindClose(hFind); + if (!ok) { + Py_DECREF(retList); + return PyWin_SetAPIError("FindNextFileW"); + } + return retList; + } + PyCFunction pfnpy_FindFilesW=(PyCFunction)py_FindFilesW; + + // @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. + // @comm Accepts keyword args. + // @comm FindFirstFileTransacted will be called if a transaction handle is passed in. + static PyObject *py_FindFilesIterator(PyObject *self, PyObject *args, PyObject *kwargs) + { + WCHAR *fileSpec; + HANDLE htrans; + PyObject *obfileSpec, *obtrans=Py_None; + static char *keywords[]={"FileName","Transaction", NULL}; + + if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O|O:FindFilesIterator", keywords, + &obfileSpec, // @pyparm string|FileName||A string that specifies a valid directory or path and filename, which can contain wildcard characters (* and ?). + &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction, can be None. + // If this parameter is not None, FindFirstFileTransacted will be called to perform a transacted search + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, TRUE)) + return NULL; + if (htrans!=NULL) + CHECK_PFN(FindFirstFileTransacted); + 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 + if (htrans!=NULL) + it->hFind=(*pfnFindFirstFileTransacted)(fileSpec, FindExInfoStandard, &it->buffer, + FindExSearchNameMatch, NULL, 0, htrans); + else + 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("FindFirstFileW"); + } + it->empty = TRUE; + } + return (PyObject *)it; + // @rdesc The result is a Python iterator, with each next() method + // returning a <o WIN32_FIND_DATA> tuple. + } + PyCFunction pfnpy_FindFilesIterator=(PyCFunction)py_FindFilesIterator; + %} %native (SetVolumeMountPoint) py_SetVolumeMountPoint; *************** *** 4634,4638 **** %native (CreateDirectoryTransacted) pfnpy_CreateDirectoryTransacted; %native (RemoveDirectoryTransacted) pfnpy_RemoveDirectoryTransacted; ! %init %{ --- 4652,4657 ---- %native (CreateDirectoryTransacted) pfnpy_CreateDirectoryTransacted; %native (RemoveDirectoryTransacted) pfnpy_RemoveDirectoryTransacted; ! %native (FindFilesW) pfnpy_FindFilesW; ! %native (FindFilesIterator) pfnpy_FindFilesIterator; %init %{ *************** *** 4655,4659 **** ||(strcmp(pmd->ml_name, "CreateDirectoryTransacted")==0) ||(strcmp(pmd->ml_name, "RemoveDirectoryTransacted")==0) ! ||(strcmp(pmd->ml_name, "FindFirstFileTransacted")==0) // not impl yet ||(strcmp(pmd->ml_name, "FindFirstStream")==0) // not impl yet ||(strcmp(pmd->ml_name, "FindFirstStreamTransacted")==0) // not impl yet --- 4674,4679 ---- ||(strcmp(pmd->ml_name, "CreateDirectoryTransacted")==0) ||(strcmp(pmd->ml_name, "RemoveDirectoryTransacted")==0) ! ||(strcmp(pmd->ml_name, "FindFilesW")==0) ! ||(strcmp(pmd->ml_name, "FindFilesIterator")==0) ||(strcmp(pmd->ml_name, "FindFirstStream")==0) // not impl yet ||(strcmp(pmd->ml_name, "FindFirstStreamTransacted")==0) // not impl yet |
From: Roger U. <ru...@us...> - 2007-02-05 07:59:59
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17808 Added Files: RegCreateKeyTransacted.py Log Message: Demo for transacted registry functions --- NEW FILE: RegCreateKeyTransacted.py --- import win32api, win32con, win32transaction keyname='Pywin32 test transacted registry functions' subkeyname='test transacted subkey' classname='Transacted Class' trans=win32transaction.CreateTransaction(Description='test RegCreateKeyTransacted') key, disp=win32api.RegCreateKeyEx(win32con.HKEY_CURRENT_USER, keyname, samDesired=win32con.KEY_ALL_ACCESS, Class=classname) ## clean up any existing keys for subk in win32api.RegEnumKeyExW(key): win32api.RegDeleteKey(key, subk[0]) ## reopen key in transacted mode transacted_key=win32api.RegOpenKeyTransacted(Key=win32con.HKEY_CURRENT_USER, SubKey=keyname, Transaction=trans, samDesired=win32con.KEY_ALL_ACCESS) subkey, disp=win32api.RegCreateKeyTransacted(transacted_key, subkeyname, Transaction=trans, samDesired=win32con.KEY_ALL_ACCESS, Class=classname) ## Newly created key should not be visible from non-transacted handle subkeys=[s[0] for s in win32api.RegEnumKeyExW(key)] assert subkeyname not in subkeys transacted_subkeys=[s[0] for s in win32api.RegEnumKeyExW(transacted_key)] assert subkeyname in transacted_subkeys ## Key should be visible to non-transacted handle after commit win32transaction.CommitTransaction(trans) subkeys=[s[0] for s in win32api.RegEnumKeyExW(key)] assert subkeyname in subkeys ## test transacted delete del_trans=win32transaction.CreateTransaction(Description='test RegDeleteKeyTransacted') win32api.RegDeleteKeyTransacted(key, subkeyname, Transaction=del_trans) ## subkey should still show up for non-transacted handle subkeys=[s[0] for s in win32api.RegEnumKeyExW(key)] assert subkeyname in subkeys ## ... and should be gone after commit win32transaction.CommitTransaction(del_trans) subkeys=[s[0] for s in win32api.RegEnumKeyExW(key)] assert subkeyname not in subkeys win32api.RegDeleteKey(win32con.HKEY_CURRENT_USER, keyname) |
From: Roger U. <ru...@us...> - 2007-02-05 07:53:09
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14723 Modified Files: win32apimodule.cpp Log Message: Add transacted registry functions More compatibility fixes Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** win32apimodule.cpp 13 Jan 2007 09:35:16 -0000 1.69 --- win32apimodule.cpp 5 Feb 2007 07:53:08 -0000 1.70 *************** *** 60,63 **** --- 60,71 ---- static RegSaveKeyExfunc pfnRegSaveKeyEx=NULL; + typedef LONG (WINAPI *RegCreateKeyTransactedfunc)(HKEY,LPWSTR,DWORD,LPWSTR,DWORD, + REGSAM,LPSECURITY_ATTRIBUTES,PHKEY,LPDWORD,HANDLE,PVOID); + static RegCreateKeyTransactedfunc pfnRegCreateKeyTransacted=NULL; + typedef LONG (WINAPI *RegDeleteKeyTransactedfunc)(HKEY,LPWSTR,REGSAM,DWORD,HANDLE,PVOID); + static RegDeleteKeyTransactedfunc pfnRegDeleteKeyTransacted = NULL; + typedef LONG (WINAPI *RegOpenKeyTransactedfunc)(HKEY,LPWSTR,DWORD,REGSAM,PHKEY,HANDLE,PVOID); + static RegOpenKeyTransactedfunc pfnRegOpenKeyTransacted = NULL; + /* error helper */ *************** *** 430,434 **** PyW32_END_ALLOW_THREADS if (rc<=(HINSTANCE)32) { ! if ((int)rc==31) return ReturnError("There is no association for the file"); return ReturnAPIError("FindExecutable", (int)rc ); --- 438,442 ---- PyW32_END_ALLOW_THREADS if (rc<=(HINSTANCE)32) { ! if (rc==(HINSTANCE)31) return ReturnError("There is no association for the file"); return ReturnAPIError("FindExecutable", (int)rc ); *************** *** 1334,1349 **** PyVkKeyScanEx(PyObject * self, PyObject * args) { ! char *key; ! int len; ! long kl; ! // @pyparm chr|char||Specifies a character ! if (!PyArg_ParseTuple(args, "s#l:VkKeyScanEx", &key, &len, &kl)) return (NULL); ! if (len != 1) ! return PyErr_Format(PyExc_ValueError, "arg must be a string of length 1"); int ret; PyW32_BEGIN_ALLOW_THREADS // @pyseeapi VkKeyScanEx ! ret = VkKeyScanEx(key[0], (HKL)kl); PyW32_END_ALLOW_THREADS return PyInt_FromLong(ret); --- 1342,1358 ---- PyVkKeyScanEx(PyObject * self, PyObject * args) { ! char key; ! HKL hkl; ! PyObject *obhkl; ! if (!PyArg_ParseTuple(args, "cO:VkKeyScanEx", ! &key, // @pyparm chr|char||Specifies a character ! &obhkl)) // @pyparm <o PyHANDLE>|hkl||Handle to a keyboard layout at returned by <om win32api.LoadKeyboardLayout> return (NULL); ! if (!PyWinObject_AsHANDLE(obhkl, (HANDLE *)&hkl, FALSE)) ! return NULL; int ret; PyW32_BEGIN_ALLOW_THREADS // @pyseeapi VkKeyScanEx ! ret = VkKeyScanEx(key, hkl); PyW32_END_ALLOW_THREADS return PyInt_FromLong(ret); *************** *** 2547,2550 **** --- 2556,2607 ---- } + // @pymethod <o PyHKEY>, int|win32api|RegCreateKeyTransacted|Creates a registry key as part of a transaction + // @rdesc Returns a transacted handle and disposition flag (winnt.REG_CREATED_NEW_KEY or winnt.REG_OPENED_EXISTING_KEY) + // @pyseeapi RegCreateKeyTransacted + // @comm Accepts keyword args. + // @comm Requires Vista or later. + static PyObject *PyRegCreateKeyTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(RegCreateKeyTransacted); + HKEY hKey; + PyObject *obKey, *obsubKey, *obtrans, *obclass=Py_None, *obsa=Py_None, *ret=NULL; + WCHAR *subKey=NULL, *class_name=NULL; + PSECURITY_ATTRIBUTES psa; + REGSAM access; + DWORD disp, options=REG_OPTION_NON_VOLATILE, reserved=0; + PVOID extparam=NULL; // Documented as Reserved + HKEY retKey; + HANDLE htrans; + long rc; + static char *keywords[]={"Key","SubKey","samDesired","Transaction","Class","Options","SecurityAttributes", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOkO|OkO:RegCreateKeyTransacted", keywords, + &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values + &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to open or create. + &access, // @pyparm int|samDesired||Access allowed to handle, combination of win32con.KEY_* constants. Can also contain + // standard access rights such as DELETE, WRITE_OWNER, etc. + &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction as returned by <om win32transaction.CreateTransaction> + &obclass, // @pyparm <o PyUnicode>|Class|None|Name of registry key class + &options, // @pyparm int|Options|REG_OPTION_NON_VOLATILE|One of the winnt.REG_OPTION_* values + &obsa)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Specifies security for key and handle inheritance + return NULL; + if (PyWinObject_AsHKEY(obKey, &hKey) + &&PyWinObject_AsWCHAR(obsubKey, &subKey, FALSE) + &&PyWinObject_AsHANDLE(obtrans, &htrans, FALSE) + &&PyWinObject_AsWCHAR(obclass, &class_name, TRUE) + &&PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)){ + rc=(*pfnRegCreateKeyTransacted)(hKey, subKey, reserved, class_name, options, + access, psa, &retKey, &disp, htrans, extparam); + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegCreateKeyTransacted", rc); + else + ret=Py_BuildValue("Nk", PyWinObject_FromHKEY(retKey), disp); + } + + PyWinObject_FreeWCHAR(subKey); + PyWinObject_FreeWCHAR(class_name); + return ret; + } + // @pymethod |win32api|RegDeleteKey|Deletes the specified key. This method can not delete keys with subkeys. static PyObject * *************** *** 2572,2575 **** --- 2629,2671 ---- // If the method fails, and exception is raised. } + + // @pymethod |win32api|RegDeleteKeyTransacted|Deletes a registry key as part of a transaction + // @comm Accepts keyword args. + // @comm Requires Vista or later. + // @comm Key to be deleted cannot contain subkeys + static PyObject *PyRegDeleteKeyTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(RegDeleteKeyTransacted); + HKEY hKey; + PyObject *obKey, *obsubKey, *obtrans, *ret=NULL; + PVOID extparam=NULL; // Reserved, ignore for now + WCHAR *subKey=NULL, *class_name=NULL; + REGSAM access=0; + DWORD reserved=0; + HANDLE htrans; + long rc; + static char *keywords[]={"Key","SubKey","Transaction","samDesired", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|k:RegDeleteKeyTransacted", keywords, + &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values + &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to be deleted. + &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction as returned by <om win32transaction.CreateTransaction> + &access)) // @pyparm int|samDesired|0|Can be KEY_WOW64_32KEY or KEY_WOW64_64KEY to specify alternate registry view + return NULL; + if (PyWinObject_AsHKEY(obKey, &hKey) + &&PyWinObject_AsWCHAR(obsubKey, &subKey, FALSE) + &&PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)){ + rc=(*pfnRegDeleteKeyTransacted)(hKey, subKey, access, reserved, htrans, extparam); + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegDeleteKeyTransacted", rc); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PyWinObject_FreeWCHAR(subKey); + return ret; + } + // @pymethod |win32api|RegDeleteValue|Removes a named value from the specified registry key. static PyObject * *************** *** 3168,3171 **** --- 3264,3307 ---- } + // @pymethod <o PyHKEY>|win32api|RegOpenKeyTransacted|Opens a registry key as part of a transaction + // @rdesc Returns a transacted registry handle. Note that operations on subkeys are not automatically transacted. + // @pyseeapi RegOpenKeyTransacted + // @comm Accepts keyword arguments. + // @comm Requires Vista or later. + static PyObject *PyRegOpenKeyTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(RegOpenKeyTransacted); + HKEY hKey; + PyObject *obKey, *obsubKey, *obtrans, *ret=NULL; + WCHAR *subKey=NULL; + REGSAM access; + DWORD options=0; // Reserved + PVOID extparam=NULL; // Reserved, not accepted as arg for now + HKEY retKey; + HANDLE htrans; + long rc; + static char *keywords[]={"Key","SubKey","samDesired","Transaction","Options", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOkO|k:RegOpenKeyTransacted", keywords, + &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values + &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to open. Can be None to reopen an existing key. + &access, // @pyparm int|samDesired||Access allowed to handle, combination of win32con.KEY_* constants. Can also contain + // standard access rights such as DELETE, WRITE_OWNER, etc. + &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction as returned by <om win32transaction.CreateTransaction> + &options)) // @pyparm int|Options|0|Reserved, use only 0 + return NULL; + if (PyWinObject_AsHKEY(obKey, &hKey) + &&PyWinObject_AsWCHAR(obsubKey, &subKey, TRUE) + &&PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)){ + rc=(*pfnRegOpenKeyTransacted)(hKey, subKey, options, access, &retKey, htrans, extparam); + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegOpenKeyTransacted", rc); + else + ret=PyWinObject_FromHKEY(retKey); + } + PyWinObject_FreeWCHAR(subKey); + return ret; + } + // @pymethod (int, int, long)|win32api|RegQueryInfoKey|Returns the number of // subkeys, the number of values a key has, *************** *** 3787,3791 **** return ReturnAPIError("ShellExecute", (int)rc ); } ! return Py_BuildValue("i", rc ); // @rdesc The instance handle of the application that was run. (This handle could also be the handle of a dynamic data exchange [DDE] server application.) // If there is an error, the method raises an exception. --- 3923,3927 ---- return ReturnAPIError("ShellExecute", (int)rc ); } ! return PyLong_FromVoidPtr(rc); // @rdesc The instance handle of the application that was run. (This handle could also be the handle of a dynamic data exchange [DDE] server application.) // If there is an error, the method raises an exception. *************** *** 3838,3842 **** UINT cmd; PyObject *dataOb = Py_None; ! DWORD data; if (!PyArg_ParseTuple(args, "Osi|O:WinHelp", &obhwnd, // @pyparm int|hwnd||The handle of the window requesting help. --- 3974,3978 ---- UINT cmd; PyObject *dataOb = Py_None; ! ULONG_PTR data; if (!PyArg_ParseTuple(args, "Osi|O:WinHelp", &obhwnd, // @pyparm int|hwnd||The handle of the window requesting help. *************** *** 3850,3860 **** data = 0; else if (PyString_Check(dataOb)) ! data = (DWORD)PyString_AsString(dataOb); ! else if (PyInt_Check(dataOb)) ! data = (DWORD)PyInt_AsLong(dataOb); ! else { ! PyErr_SetString(PyExc_TypeError, "4th argument must be a None, string or an integer."); ! return NULL; ! } PyW32_BEGIN_ALLOW_THREADS --- 3986,3997 ---- data = 0; else if (PyString_Check(dataOb)) ! data = (ULONG_PTR)PyString_AsString(dataOb); ! else{ ! data = (ULONG_PTR)PyLong_AsVoidPtr(dataOb); ! if (data==NULL && PyErr_Occurred()){ ! PyErr_SetString(PyExc_TypeError, "4th argument must be a None, string or an integer."); ! return NULL; ! } ! } PyW32_BEGIN_ALLOW_THREADS *************** *** 4604,4612 **** // @rdesc The result is a list of string or integers, one for each resource enumerated. PyObject *result = PyList_New(0); EnumResourceNames( hmodule, restype, reinterpret_cast<ENUMRESNAMEPROC>(EnumResProc), ! reinterpret_cast<LONG>(result)); return result; --- 4741,4751 ---- // @rdesc The result is a list of string or integers, one for each resource enumerated. PyObject *result = PyList_New(0); + if (result==NULL) + return NULL; EnumResourceNames( hmodule, restype, reinterpret_cast<ENUMRESNAMEPROC>(EnumResProc), ! reinterpret_cast<LONG_PTR>(result)); return result; *************** *** 4641,4645 **** if(!EnumResourceTypesW(hmodule, reinterpret_cast<ENUMRESTYPEPROCW>(EnumResourceTypesProc), ! reinterpret_cast<LONG>(ret))){ Py_DECREF(ret); ret=NULL; --- 4780,4784 ---- if(!EnumResourceTypesW(hmodule, reinterpret_cast<ENUMRESTYPEPROCW>(EnumResourceTypesProc), ! reinterpret_cast<LONG_PTR>(ret))){ Py_DECREF(ret); ret=NULL; *************** *** 4682,4686 **** resname, reinterpret_cast<ENUMRESLANGPROCW>(EnumResourceLanguagesProc), ! reinterpret_cast<LONG>(ret))){ Py_DECREF(ret); ret=NULL; --- 4821,4825 ---- resname, reinterpret_cast<ENUMRESLANGPROCW>(EnumResourceLanguagesProc), ! reinterpret_cast<LONG_PTR>(ret))){ Py_DECREF(ret); ret=NULL; *************** *** 5164,5168 **** if (ret!=NULL){ for (int tuple_ind=0;tuple_ind<buflen;tuple_ind++){ ! PyObject *tuple_item=PyLong_FromLong((long)buf[tuple_ind]); if (tuple_item==NULL){ Py_DECREF(ret); --- 5303,5307 ---- if (ret!=NULL){ for (int tuple_ind=0;tuple_ind<buflen;tuple_ind++){ ! PyObject *tuple_item=PyWinLong_FromHANDLE(buf[tuple_ind]); if (tuple_item==NULL){ Py_DECREF(ret); *************** *** 5192,5196 **** if (lcid==NULL) return PyWin_SetAPIError("LoadKeyboardLayout"); ! return PyLong_FromLong((long)lcid); } --- 5331,5335 ---- if (lcid==NULL) return PyWin_SetAPIError("LoadKeyboardLayout"); ! return PyWinLong_FromHANDLE(lcid); } *************** *** 5374,5378 **** --- 5513,5519 ---- {"RegCreateKey", PyRegCreateKey, 1}, // @pymeth RegCreateKey|Creates the specified key, or opens the key if it already exists. {"RegCreateKeyEx", (PyCFunction)PyRegCreateKeyEx, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCreateKeyEx|Extended version of RegCreateKey + {"RegCreateKeyTransacted",(PyCFunction)PyRegCreateKeyTransacted, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCreateKeyTransacted|Creates a registry key as part of a transaction {"RegDeleteKey", PyRegDeleteKey, 1}, // @pymeth RegDeleteKey|Deletes the specified key. + {"RegDeleteKeyTransacted",(PyCFunction)PyRegDeleteKeyTransacted, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegDeleteKeyTransacted|Deletes a registry key as part of a transaction {"RegDeleteValue", PyRegDeleteValue, 1}, // @pymeth RegDeleteValue|Removes a named value from the specified registry key. {"RegEnumKey", PyRegEnumKey, 1}, // @pymeth RegEnumKey|Enumerates subkeys of the specified open registry key. *************** *** 5385,5388 **** --- 5526,5530 ---- {"RegOpenKey", PyRegOpenKey, 1}, // @pymeth RegOpenKey|Alias for <om win32api.RegOpenKeyEx> {"RegOpenKeyEx", PyRegOpenKey, 1}, // @pymeth RegOpenKeyEx|Opens the specified key. + {"RegOpenKeyTransacted",(PyCFunction)PyRegOpenKeyTransacted, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegOpenKeyTransacted|Opens a registry key as part of a transaction. {"RegQueryValue", PyRegQueryValue, 1}, // @pymeth RegQueryValue|Retrieves the value associated with the unnamed value for a specified key in the registry. {"RegQueryValueEx", PyRegQueryValueEx, 1}, // @pymeth RegQueryValueEx|Retrieves the type and data for a specified value name associated with an open registry key. *************** *** 5548,5551 **** --- 5690,5696 ---- pfnRegRestoreKey=(RegRestoreKeyfunc)GetProcAddress(hmodule, "RegRestoreKeyW"); pfnRegSaveKeyEx=(RegSaveKeyExfunc)GetProcAddress(hmodule, "RegSaveKeyExW"); + pfnRegCreateKeyTransacted=(RegCreateKeyTransactedfunc)GetProcAddress(hmodule, "RegCreateKeyTransactedW"); + pfnRegOpenKeyTransacted=(RegOpenKeyTransactedfunc)GetProcAddress(hmodule, "RegOpenKeyTransactedW"); + pfnRegDeleteKeyTransacted=(RegDeleteKeyTransactedfunc)GetProcAddress(hmodule, "RegDeleteKeyTransactedW"); } |
From: Roger U. <ru...@us...> - 2007-02-05 01:46:41
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7130/win32/Lib Modified Files: win32con.py Log Message: Add some newer registry contstants Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** win32con.py 24 Dec 2006 06:00:13 -0000 1.17 --- win32con.py 5 Feb 2007 01:46:40 -0000 1.18 *************** *** 2271,2274 **** --- 2271,2277 ---- KEY_NOTIFY = (16) KEY_CREATE_LINK = (32) + KEY_WOW64_32KEY = 512 + KEY_WOW64_64KEY = 256 + KEY_WOW64_RES = 768 KEY_READ = ((STANDARD_RIGHTS_READ |\ KEY_QUERY_VALUE |\ *************** *** 2579,2582 **** --- 2582,2587 ---- SP_OUTOFMEMORY = (-5) PR_JOBSTATUS = 0 + + ## GDI object types OBJ_PEN = 1 OBJ_BRUSH = 2 *************** *** 2592,2595 **** --- 2597,2602 ---- OBJ_ENHMETADC = 12 OBJ_ENHMETAFILE = 13 + OBJ_COLORSPACE = 14 + MWT_IDENTITY = 1 MWT_LEFTMULTIPLY = 2 *************** *** 3120,3123 **** --- 3127,3141 ---- DMNUP_ONEUP = 2 + # used with ExtEscape + FEATURESETTING_NUP = 0 + FEATURESETTING_OUTPUT = 1 + FEATURESETTING_PSLEVEL = 2 + FEATURESETTING_CUSTPAPER = 3 + FEATURESETTING_MIRROR = 4 + FEATURESETTING_NEGATIVE = 5 + FEATURESETTING_PROTOCOL = 6 + FEATURESETTING_PRIVATE_BEGIN = 0x1000 + FEATURESETTING_PRIVATE_END = 0x1FFF + RDH_RECTANGLES = 1 GGO_METRICS = 0 |
From: Mark H. <mha...@us...> - 2007-02-04 22:11:14
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21341 Modified Files: PyWinTypesmodule.cpp Log Message: Have pywintypes.OVERLAPPEDType point at the correct type (it used to refer to the HANDLE type!) Thanks to Troels Walsted Hansen for noticing. Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PyWinTypesmodule.cpp 27 Dec 2006 04:41:14 -0000 1.23 --- PyWinTypesmodule.cpp 4 Feb 2007 22:11:11 -0000 1.24 *************** *** 647,651 **** #endif PyDict_SetItemString(dict, "HANDLEType", (PyObject *)&PyHANDLEType); ! PyDict_SetItemString(dict, "OVERLAPPEDType", (PyObject *)&PyHANDLEType); PyDict_SetItemString(dict, "DEVMODEType", (PyObject *)&PyDEVMODEType); PyDict_SetItemString(dict, "WAVEFORMATEXType", (PyObject *)&PyWAVEFORMATEXType); --- 647,651 ---- #endif PyDict_SetItemString(dict, "HANDLEType", (PyObject *)&PyHANDLEType); ! PyDict_SetItemString(dict, "OVERLAPPEDType", (PyObject *)&PyOVERLAPPEDType); PyDict_SetItemString(dict, "DEVMODEType", (PyObject *)&PyDEVMODEType); PyDict_SetItemString(dict, "WAVEFORMATEXType", (PyObject *)&PyWAVEFORMATEXType); |
From: Roger U. <ru...@us...> - 2007-02-03 22:33:37
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24979/win32/src Modified Files: win32file.i Log Message: Add transactional NTFS functions Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** win32file.i 17 Jan 2007 14:33:42 -0000 1.69 --- win32file.i 3 Feb 2007 22:33:32 -0000 1.70 *************** *** 10,14 **** //#define FAR #ifndef _WIN32_WINNT ! #define _WIN32_WINNT 0x0500 #endif #include "winsock2.h" --- 10,14 ---- //#define FAR #ifndef _WIN32_WINNT ! #define _WIN32_WINNT 0x0501 #endif #include "winsock2.h" *************** *** 30,35 **** #define FILE_ALL_ACCESS FILE_ALL_ACCESS - #define INVALID_HANDLE_VALUE (long)INVALID_HANDLE_VALUE - #define GENERIC_READ GENERIC_READ // Specifies read access to the object. Data can be read from the file and the file pointer can be moved. Combine with GENERIC_WRITE for read-write access. --- 30,33 ---- *************** *** 2765,2769 **** static BOOL (WINAPI *pfnSetVolumeMountPointW)(LPCWSTR, LPCWSTR) = NULL; static BOOL (WINAPI *pfnDeleteVolumeMountPointW)(LPCWSTR) = NULL; - static BOOL (WINAPI *pfnCreateHardLinkW)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES ) = NULL; static BOOL (WINAPI *pfnEncryptFile)(WCHAR *)=NULL; static BOOL (WINAPI *pfnDecryptFile)(WCHAR *, DWORD)=NULL; --- 2763,2766 ---- *************** *** 2777,2780 **** --- 2774,2785 ---- static BOOL (WINAPI *pfnGetVolumePathNameW)(WCHAR *, WCHAR *, DWORD)=NULL; + typedef BOOL (WINAPI *CreateHardLinkfunc)(LPWSTR, LPWSTR, LPSECURITY_ATTRIBUTES); + static CreateHardLinkfunc pfnCreateHardLink=NULL; + typedef BOOL (WINAPI *CreateHardLinkTransactedfunc)(LPWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, HANDLE); + static CreateHardLinkTransactedfunc pfnCreateHardLinkTransacted=NULL; + typedef BOOL (WINAPI *CreateSymbolicLinkfunc)(LPWSTR,LPWSTR,DWORD); + static CreateSymbolicLinkfunc pfnCreateSymbolicLink=NULL; + typedef BOOL (WINAPI *CreateSymbolicLinkTransactedfunc)(LPCWSTR,LPCWSTR,DWORD,HANDLE); + static CreateSymbolicLinkTransactedfunc pfnCreateSymbolicLinkTransacted=NULL; typedef BOOL (WINAPI *BackupReadfunc)(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*); *************** *** 2803,2806 **** --- 2808,2848 ---- static CloseEncryptedFileRawfunc pfnCloseEncryptedFileRaw=NULL; + // Transactional NTFS functions + typedef HANDLE (WINAPI *CreateFileTransactedfunc)(LPWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE,HANDLE,PUSHORT,PVOID); + static CreateFileTransactedfunc pfnCreateFileTransacted=NULL; + typedef BOOL (WINAPI *DeleteFileTransactedfunc)(LPWSTR,HANDLE); + static DeleteFileTransactedfunc pfnDeleteFileTransacted=NULL; + typedef BOOL (WINAPI *MoveFileTransactedfunc)(LPWSTR,LPWSTR,LPPROGRESS_ROUTINE,LPVOID,DWORD,HANDLE); + static MoveFileTransactedfunc pfnMoveFileTransacted=NULL; + typedef BOOL (WINAPI *CopyFileTransactedfunc)(LPWSTR,LPWSTR,LPPROGRESS_ROUTINE,LPVOID,LPBOOL,DWORD,HANDLE); + static CopyFileTransactedfunc pfnCopyFileTransacted=NULL; + typedef DWORD (WINAPI *GetFileAttributesTransactedfunc)(LPWSTR,GET_FILEEX_INFO_LEVELS,LPVOID,HANDLE); + static GetFileAttributesTransactedfunc pfnGetFileAttributesTransacted=NULL; + typedef BOOL (WINAPI *SetFileAttributesTransactedfunc)(LPWSTR,DWORD,HANDLE); + static SetFileAttributesTransactedfunc pfnSetFileAttributesTransacted=NULL; + typedef BOOL (WINAPI *CreateDirectoryTransactedfunc)(LPWSTR,LPWSTR,LPSECURITY_ATTRIBUTES,HANDLE); + static CreateDirectoryTransactedfunc pfnCreateDirectoryTransacted=NULL; + typedef BOOL (WINAPI *RemoveDirectoryTransactedfunc)(LPWSTR,HANDLE); + static RemoveDirectoryTransactedfunc pfnRemoveDirectoryTransacted=NULL; + + // These aren't used yet + typedef HANDLE (WINAPI *FindFirstStreamfunc)(LPWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD); + static FindFirstStreamfunc pfnFindFirstStream=NULL; + typedef BOOL (WINAPI *FindNextStreamfunc)(HANDLE, LPVOID); + static FindNextStreamfunc pfnFindNextStream=NULL; + typedef HANDLE (WINAPI *FindFirstStreamTransactedfunc)(LPWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD, HANDLE); + static FindFirstStreamTransactedfunc pfnFindFirstStreamTransacted=NULL; + typedef HANDLE (WINAPI *FindFirstFileTransactedfunc)(LPWSTR,FINDEX_INFO_LEVELS,LPVOID,FINDEX_SEARCH_OPS,LPVOID,DWORD,HANDLE); + static FindFirstFileTransactedfunc pfnFindFirstFileTransacted=NULL; + typedef DWORD (WINAPI *GetFullPathNameTransactedfunc)(LPCTSTR,DWORD,LPTSTR,LPTSTR*,HANDLE); + static GetFullPathNameTransactedfunc pfnGetFullPathNameTransacted = NULL; + typedef DWORD (WINAPI *GetLongPathNameTransactedfunc)(LPCTSTR,LPTSTR,DWORD,HANDLE); + static GetLongPathNameTransactedfunc pfnGetLongPathNameTransacted = 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 + typedef BOOL (WINAPI *GetFileInformationByHandleExfunc)(HANDLE,FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD); + static GetFileInformationByHandleExfunc pfnGetFileInformationByHandleEx = NULL; + */ + // @pyswig <o PyUnicode>|SetVolumeMountPoint|Mounts the specified volume at the specified volume mount point. *************** *** 2896,2900 **** // @pyswig |CreateHardLink|Establishes an NTFS hard link between an existing file and a new file. static PyObject* ! py_CreateHardLink(PyObject *self, PyObject *args) { // @comm An NTFS hard link is similar to a POSIX hard link. --- 2938,2942 ---- // @pyswig |CreateHardLink|Establishes an NTFS hard link between an existing file and a new file. static PyObject* ! py_CreateHardLink(PyObject *self, PyObject *args, PyObject *kwargs) { // @comm An NTFS hard link is similar to a POSIX hard link. *************** *** 2904,2954 **** // it and the original file will still remain. // @ex Usage|CreateHardLink('h:\dir\newfilename.txt','h:\otherdir\existingfile.txt') ! // @pyparm string|fileName||The name of the new directory entry to be created. ! // @pyparm string|existingName||The name of the existing file to which the new link will point. ! // @pyparm <o PySECURITY_ATTRIBUTES>|security||a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new file. ! // If this parameter is None, it leaves the file's existing security descriptor unmodified. ! // If this parameter is not None, it modifies the file's security descriptor. ! // @comm This method exists only on Windows 2000.If there ! // is an attempt to use it on these platforms, an error with E_NOTIMPL will be raised. ! PyObject *ret=NULL; ! PyObject *new_file_obj; ! PyObject *existing_file_obj; ! PyObject *sa_obj = Py_None; ! WCHAR *new_file = NULL; ! WCHAR *existing_file = NULL; ! SECURITY_ATTRIBUTES *sa; ! if (pfnCreateHardLinkW==NULL) ! return PyErr_Format(PyExc_NotImplementedError,"CreateHardLink not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"OO|O:CreateHardLink", &new_file_obj, &existing_file_obj, &sa_obj)) ! return NULL; ! if (!PyWinObject_AsWCHAR(new_file_obj, &new_file, false)){ ! PyErr_SetString(PyExc_TypeError,"New file name must be string or unicode"); ! goto cleanup; ! } ! if (!PyWinObject_AsWCHAR(existing_file_obj, &existing_file, false)){ ! PyErr_SetString(PyExc_TypeError,"Existing file name must be string or unicode"); ! goto cleanup; ! } ! if (!PyWinObject_AsSECURITY_ATTRIBUTES(sa_obj, &sa, true)){ ! PyErr_SetString(PyExc_TypeError,"3rd param must be a SECURITY_ATTRIBUTES, or None"); ! goto cleanup; ! } ! if (!((*pfnCreateHardLinkW)(new_file, existing_file, sa))){ ! PyWin_SetAPIError("CreateHardLink"); ! goto cleanup; ! } ! ret=Py_None; ! Py_INCREF(Py_None); ! cleanup: ! PyWinObject_FreeWCHAR(new_file); ! PyWinObject_FreeWCHAR(existing_file); ! return ret; } // @pyswig <o PyUnicode>|GetVolumeNameForVolumeMountPoint|Returns unique volume name (Win2k or later) --- 2946,3089 ---- // it and the original file will still remain. // @ex Usage|CreateHardLink('h:\dir\newfilename.txt','h:\otherdir\existingfile.txt') ! // @comm This method exists on Windows 2000 and later. Otherwise NotImplementedError will be raised. ! // @comm Accepts keyword args. ! CHECK_PFN(CreateHardLink); ! PyObject *ret=NULL; ! PyObject *new_file_obj; ! PyObject *existing_file_obj; ! PyObject *sa_obj = Py_None; ! WCHAR *new_file = NULL; ! WCHAR *existing_file = NULL; ! SECURITY_ATTRIBUTES *sa; ! static char *keywords[]={"FileName","ExistingFileName","SecurityAttributes", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O:CreateHardLink", keywords, ! &new_file_obj, // @pyparm <o PyUnicode>|FileName||The name of the new directory entry to be created. ! &existing_file_obj, // @pyparm <o PyUnicode>|ExistingFileName||The name of the existing file to which the new link will point. ! &sa_obj)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Optional SECURITY_ATTRIBUTES object. MSDN describes this parameter as reserved, so use only None, ! return NULL; ! if (!PyWinObject_AsSECURITY_ATTRIBUTES(sa_obj, &sa, TRUE)) ! return NULL; ! if (PyWinObject_AsWCHAR(new_file_obj, &new_file, FALSE) ! &&PyWinObject_AsWCHAR(existing_file_obj, &existing_file, FALSE)){ ! if (!(*pfnCreateHardLink)(new_file, existing_file, sa)) ! PyWin_SetAPIError("CreateHardLink"); ! else{ ! Py_INCREF(Py_None); ! ret=Py_None; ! } ! } ! PyWinObject_FreeWCHAR(new_file); ! PyWinObject_FreeWCHAR(existing_file); ! return ret; ! } ! PyCFunction pfnpy_CreateHardLink=(PyCFunction)py_CreateHardLink; ! // @pyswig |CreateHardLinkTransacted|Creates an NTFS hard link as part of a transaction ! static PyObject *py_CreateHardLinkTransacted(PyObject *self, PyObject *args, PyObject *kwargs) ! { ! // @comm This method only exists on Vista and later. ! // @comm Accepts keyword args. ! CHECK_PFN(CreateHardLinkTransacted); ! PyObject *obtrans, *ret=NULL; ! PyObject *new_file_obj; ! PyObject *existing_file_obj; ! PyObject *sa_obj = Py_None; ! WCHAR *new_file = NULL; ! WCHAR *existing_file = NULL; ! SECURITY_ATTRIBUTES *sa; ! HANDLE htrans; ! static char *keywords[]={"FileName","ExistingFileName","Transaction","SecurityAttributes", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|O:CreateHardLinkTransacted", keywords, ! &new_file_obj, // @pyparm <o PyUnicode>|FileName||The name of the new directory entry to be created. ! &existing_file_obj, // @pyparm <o PyUnicode>|ExistingFileName||The name of the existing file to which the new link will point. ! &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction ! &sa_obj)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Optional SECURITY_ATTRIBUTES object. MSDN describes this parameter as reserved, so use only None, ! return NULL; ! if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) ! return NULL; ! if (!PyWinObject_AsSECURITY_ATTRIBUTES(sa_obj, &sa, TRUE)) ! return NULL; ! if (PyWinObject_AsWCHAR(new_file_obj, &new_file, FALSE) ! &&PyWinObject_AsWCHAR(existing_file_obj, &existing_file, FALSE)){ ! if (!(*pfnCreateHardLinkTransacted)(new_file, existing_file, sa, htrans)) ! PyWin_SetAPIError("CreateHardLinkTransacted"); ! else{ ! Py_INCREF(Py_None); ! ret=Py_None; ! } ! } ! PyWinObject_FreeWCHAR(new_file); ! PyWinObject_FreeWCHAR(existing_file); ! return ret; ! } ! PyCFunction pfnpy_CreateHardLinkTransacted=(PyCFunction)py_CreateHardLinkTransacted; ! // @pyswig |CreateSymbolicLink|Creates a symbolic link (reparse point) ! static PyObject *py_CreateSymbolicLink(PyObject *self, PyObject *args, PyObject *kwargs) ! { ! // @comm This method only exists on Vista and later. ! // @comm Accepts keyword args. ! // @comm Requires SeCreateSymbolicLink priv ! CHECK_PFN(CreateSymbolicLink); ! WCHAR *linkname=NULL, *targetname=NULL; ! PyObject *oblinkname, *obtargetname, *ret=NULL; ! DWORD flags=0; ! static char *keywords[]={"SymlinkFileName","TargetFileName","Flags", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|k:CreateSymbolicLink", keywords, ! &oblinkname, // @pyparm <o PyUnicode>|SymlinkFileName||Path of the symbolic link to be created ! &obtargetname, // @pyparm <o PyUnicode>|TargetFileName||The name of file to which link will point ! &flags)) // @pyparm int|Flags|0|SYMLINK_FLAG_DIRECTORY is only defined flag ! return NULL; ! if (PyWinObject_AsWCHAR(oblinkname, &linkname, FALSE) && PyWinObject_AsWCHAR(obtargetname, &targetname, FALSE)){ ! if (!(*pfnCreateSymbolicLink)(linkname, targetname, flags)) ! PyWin_SetAPIError("CreateSymbolicLink"); ! else{ ! Py_INCREF(Py_None); ! ret=Py_None; ! } ! } ! PyWinObject_FreeWCHAR(linkname); ! PyWinObject_FreeWCHAR(targetname); ! return ret; ! } ! PyCFunction pfnpy_CreateSymbolicLink=(PyCFunction)py_CreateSymbolicLink; ! // @pyswig |CreateSymbolicLinkTransacted|Creates a symbolic link as part of a transaction ! static PyObject *py_CreateSymbolicLinkTransacted(PyObject *self, PyObject *args, PyObject *kwargs) ! { ! // @comm This method only exists on Vista and later. ! // @comm Accepts keyword args. ! // @comm Requires SeCreateSymbolicLink priv ! CHECK_PFN(CreateSymbolicLinkTransacted); ! WCHAR *linkname=NULL, *targetname=NULL; ! PyObject *oblinkname, *obtargetname, *obtrans, *ret=NULL; ! DWORD flags=0; ! HANDLE htrans; ! static char *keywords[]={"SymlinkFileName","TargetFileName","Flags","Transaction", NULL}; ! ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|k:CreateSymbolicLinkTransacted", keywords, ! &oblinkname, // @pyparm <o PyUnicode>|SymlinkFileName||Path of the symbolic link to be created ! &obtargetname, // @pyparm <o PyUnicode>|TargetFileName||The name of file to which link will point ! &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction ! &flags)) // @pyparm int|Flags|0|SYMLINK_FLAG_DIRECTORY is only defined flag ! return NULL; ! if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) ! return NULL; ! if (PyWinObject_AsWCHAR(oblinkname, &linkname, FALSE) && PyWinObject_AsWCHAR(obtargetname, &targetname, FALSE)){ ! if (!(*pfnCreateSymbolicLinkTransacted)(linkname, targetname, flags, htrans)) ! PyWin_SetAPIError("CreateSymbolicLinkTransacted"); ! else{ ! Py_INCREF(Py_None); ! ret=Py_None; ! } ! } ! PyWinObject_FreeWCHAR(linkname); ! PyWinObject_FreeWCHAR(targetname); ! return ret; } + PyCFunction pfnpy_CreateSymbolicLinkTransacted=(PyCFunction)py_CreateSymbolicLinkTransacted; // @pyswig <o PyUnicode>|GetVolumeNameForVolumeMountPoint|Returns unique volume name (Win2k or later) *************** *** 3741,3756 **** // @pyswig |CopyFileEx|Restartable file copy with optional progress routine static PyObject* ! py_CopyFileEx(PyObject *self, PyObject *args) { CHECK_PFN(CopyFileEx); PyObject *obsrc, *obdst, *obcallback=Py_None, *obdata=Py_None, *ret=NULL; WCHAR *src=NULL, *dst=NULL; ! BOOL bcancel, bsuccess; LPPROGRESS_ROUTINE callback=NULL; LPVOID callback_data=NULL; PyObject *callback_objects[2]; DWORD flags=0; ! if (!PyArg_ParseTuple(args, "OO|OOik:CopyFileEx", &obsrc, // @pyparm <o PyUNICODE>|ExistingFileName||File to be copied &obdst, // @pyparm <o PyUNICODE>|NewFileName||Place to which it will be copied --- 3876,3894 ---- // @pyswig |CopyFileEx|Restartable file copy with optional progress routine + // @comm Accepts keyword args. static PyObject* ! py_CopyFileEx(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(CopyFileEx); PyObject *obsrc, *obdst, *obcallback=Py_None, *obdata=Py_None, *ret=NULL; WCHAR *src=NULL, *dst=NULL; ! BOOL bcancel=FALSE, bsuccess; LPPROGRESS_ROUTINE callback=NULL; LPVOID callback_data=NULL; PyObject *callback_objects[2]; DWORD flags=0; ! static char *keywords[]={"ExistingFileName","NewFileName","ProgressRoutine","Data","Cancel","CopyFlags", NULL}; ! ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OOik:CopyFileEx", keywords, &obsrc, // @pyparm <o PyUNICODE>|ExistingFileName||File to be copied &obdst, // @pyparm <o PyUNICODE>|NewFileName||Place to which it will be copied *************** *** 3790,3798 **** return ret; } // @pyswig |MoveFileWithProgress|Moves a file, and reports progress to a callback function // @comm Only available on Windows 2000 or later static PyObject* ! py_MoveFileWithProgress(PyObject *self, PyObject *args) { CHECK_PFN(MoveFileWithProgress); --- 3928,3997 ---- return ret; } + PyCFunction pfnpy_CopyFileEx=(PyCFunction)py_CopyFileEx; + + // @pyswig |CopyFileTransacted|Copies a file as part of a transaction + // @comm Accepts keyword arguments. + static PyObject* + py_CopyFileTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(CopyFileTransacted); + PyObject *obsrc, *obdst, *obtrans, *obcallback=Py_None, *obdata=Py_None, *ret=NULL; + WCHAR *src=NULL, *dst=NULL; + BOOL bcancel=FALSE, bsuccess; + LPPROGRESS_ROUTINE callback=NULL; + LPVOID callback_data=NULL; + PyObject *callback_objects[2]; + DWORD flags=0; + HANDLE htrans; + static char *keywords[]={"ExistingFileName","NewFileName","Transaction","ProgressRoutine","Data","Cancel","CopyFlags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|OOik:CopyFileTransacted", keywords, + &obsrc, // @pyparm <o PyUNICODE>|ExistingFileName||File to be copied + &obdst, // @pyparm <o PyUNICODE>|NewFileName||Place to which it will be copied + &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction as returned by <om win32transaction.CreateTransaction> + &obcallback, // @pyparm <o CopyProgressRoutine>|ProgressRoutine|None|A python function that receives progress updates, can be None + &obdata, // @pyparm object|Data|None|An arbitrary object to be passed to the callback function + &bcancel, // @pyparm boolean|Cancel|False|Pass True to cancel a restartable copy that was previously interrupted + &flags)) // @pyparm int|CopyFlags|0|Combination of COPY_FILE_* flags + return NULL; + + if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) + return NULL; + if (obcallback!=Py_None){ + if (!PyCallable_Check(obcallback)){ + PyErr_SetString(PyExc_TypeError,"ProgressRoutine must be callable"); + return NULL; + } + callback=CopyFileEx_ProgressRoutine; + callback_objects[0]=obcallback; + callback_objects[1]=obdata; + callback_data=callback_objects; + } + + if (PyWinObject_AsWCHAR(obsrc, &src, FALSE) && PyWinObject_AsWCHAR(obdst, &dst, FALSE)){ + Py_BEGIN_ALLOW_THREADS + bsuccess=(*pfnCopyFileTransacted)(src, dst, callback, callback_data, &bcancel, flags, htrans); + Py_END_ALLOW_THREADS + if (!bsuccess){ + // progress routine may have already thrown an exception + if (!PyErr_Occurred()) + PyWin_SetAPIError("CopyFileTransacted"); + } + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PyWinObject_FreeWCHAR(src); + PyWinObject_FreeWCHAR(dst); + return ret; + } + PyCFunction pfnpy_CopyFileTransacted=(PyCFunction)py_CopyFileTransacted; // @pyswig |MoveFileWithProgress|Moves a file, and reports progress to a callback function // @comm Only available on Windows 2000 or later + // @comm Accepts keyword arguments. static PyObject* ! py_MoveFileWithProgress(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(MoveFileWithProgress); *************** *** 3804,3808 **** PyObject *callback_objects[2]; DWORD flags=0; ! if (!PyArg_ParseTuple(args, "OO|OOk:MoveFileWithProgress", &obsrc, // @pyparm <o PyUNICODE>|ExistingFileName||File or directory to be moved &obdst, // @pyparm <o PyUNICODE>|NewFileName||Destination, can be None if flags contain MOVEFILE_DELAY_UNTIL_REBOOT --- 4003,4009 ---- PyObject *callback_objects[2]; DWORD flags=0; ! static char *keywords[]={"ExistingFileName","NewFileName","ProgressRoutine","Data","Flags", NULL}; ! ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OOk:MoveFileWithProgress", keywords, &obsrc, // @pyparm <o PyUNICODE>|ExistingFileName||File or directory to be moved &obdst, // @pyparm <o PyUNICODE>|NewFileName||Destination, can be None if flags contain MOVEFILE_DELAY_UNTIL_REBOOT *************** *** 3841,3844 **** --- 4042,4104 ---- return ret; } + PyCFunction pfnpy_MoveFileWithProgress=(PyCFunction)py_MoveFileWithProgress; + + // @pyswig |MoveFileTransacted|Moves a file or directory as part of a transaction + // @pyseeapi MoveFileTransacted + // @comm Requires Windows Vista. + // @comm Accepts keyword arguments. Implemented only as Unicode. + static PyObject *py_MoveFileTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(MoveFileTransacted); + PyObject *obsrc, *obdst, *obtrans, *obcallback=Py_None, *obdata=Py_None, *ret=NULL; + WCHAR *src=NULL, *dst=NULL; + BOOL bsuccess; + LPPROGRESS_ROUTINE callback=NULL; + LPVOID callback_data=NULL; + PyObject *callback_objects[2]; + DWORD flags=0; + HANDLE htransaction; + static char *keywords[]={"ExistingFileName","NewFileName","Transaction","ProgressRoutine","Data","Flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|OOk:MoveFileTransacted", keywords, + &obsrc, // @pyparm <o PyUNICODE>|ExistingFileName||File or directory to be moved + &obdst, // @pyparm <o PyUNICODE>|NewFileName||Destination, can be None if flags contain MOVEFILE_DELAY_UNTIL_REBOOT + &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to the transaction. See <om win32transaction.CreateTransaction>. + &obcallback, // @pyparm <o CopyProgressRoutine>|ProgressRoutine|None|A python function that receives progress updates, can be None + &obdata, // @pyparm object|Data|None|An arbitrary object to be passed to the callback function + &flags)) // @pyparm int|Flags|0|Combination of MOVEFILE_* flags + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htransaction, FALSE)) + return NULL; + if (obcallback!=Py_None){ + if (!PyCallable_Check(obcallback)){ + PyErr_SetString(PyExc_TypeError,"ProgressRoutine must be callable"); + return NULL; + } + callback=CopyFileEx_ProgressRoutine; + callback_objects[0]=obcallback; + callback_objects[1]=obdata; + callback_data=callback_objects; + } + + if (PyWinObject_AsWCHAR(obsrc, &src, FALSE) && PyWinObject_AsWCHAR(obdst, &dst, TRUE)){ + Py_BEGIN_ALLOW_THREADS + bsuccess=(*pfnMoveFileTransacted)(src, dst, callback, callback_data, flags, htransaction); + Py_END_ALLOW_THREADS + if (!bsuccess){ + // progress routine may have already thrown an exception + if (!PyErr_Occurred()) + PyWin_SetAPIError("MoveFileTransacted"); + } + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PyWinObject_FreeWCHAR(src); + PyWinObject_FreeWCHAR(dst); + return ret; + } + PyCFunction pfnpy_MoveFileTransacted=(PyCFunction)py_MoveFileTransacted; // @pyswig |ReplaceFile|Replaces one file with another *************** *** 4091,4099 **** return Py_None; } %} %native (SetVolumeMountPoint) py_SetVolumeMountPoint; %native (DeleteVolumeMountPoint) py_DeleteVolumeMountPoint; ! %native (CreateHardLink) py_CreateHardLink; %native (GetVolumeNameForVolumeMountPoint) py_GetVolumeNameForVolumeMountPoint; %native (GetVolumePathName) py_GetVolumePathName; --- 4351,4606 ---- return Py_None; } + + // @pyswig <o PyHANDLE>|CreateFileTransacted|Creates a transacted file handle. + // @pyseeapi CreateFileTransacted + // @comm Requires Windows Vista. + // @comm Accepts keyword arguments. + static PyObject *py_CreateFileTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(CreateFileTransacted); + WCHAR *filename=NULL; + PyObject *obfilename, *obsa, *obhtemplate, *obhtransaction, *obminiversion=Py_None, *obextendedparameter=Py_None; + DWORD desiredaccess, sharemode, creationdisposition, flags; + USHORT miniversion=0; + PUSHORT pminiversion=NULL; + PSECURITY_ATTRIBUTES psa; + VOID *extendedparameter=NULL; + HANDLE htemplate, htransaction, hret; + static char *keywords[]={"FileName","DesiredAccess","ShareMode","SecurityAttributes","CreationDisposition", + "FlagsAndAttributes","TemplateFile","Transaction","MiniVersion","ExtendedParameter", NULL}; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OkkOkkOO|OO:CreateFileTransacted", keywords, + &obfilename, // @pyparm <o PyUnicode>|FileName||Name of file + &desiredaccess, // @pyparm int|DesiredAccess||Combination of access mode flags. See MSDN docs. + &sharemode, // @pyparm int|ShareMode||Combination of FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_SHARE_DELETE + &obsa, // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes||Specifies security descriptor and handle inheritance, can be None + &creationdisposition, // @pyparm int|CreationDisposition||One of CREATE_ALWAYS,CREATE_NEW,OPEN_ALWAYS,OPEN_EXISTING or TRUNCATE_EXISTING + &flags, // @pyparm int|FlagsAndAttributes||Combination of FILE_ATTRIBUTE_* and FILE_FLAG_* flags + &obhtemplate, // @pyparm <o PyHANDLE>|TemplateFile||Handle to file to be used as template, can be None + &obhtransaction, // @pyparm <o PyHANDLE>|Transaction||Handle to the transaction as returned by <om win32transaction.CreateTransaction> + &obminiversion, // @pyparm int|MiniVersion|None|Transacted version of file to open, can be None + &obextendedparameter)) // @pyparm None|ExtendedParameter|None|Reserved, use only None + return NULL; + + if (!PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)) + return NULL; + if (!PyWinObject_AsHANDLE(obhtemplate, &htemplate, TRUE)) + return NULL; + if (!PyWinObject_AsHANDLE(obhtransaction, &htransaction, FALSE)) + return NULL; + if (obextendedparameter!=Py_None){ + PyErr_SetString(PyExc_TypeError,"ExtendedParameter must be None"); + return NULL; + } + if (obminiversion!=Py_None){ + long longversion=PyInt_AsLong(obminiversion); + if (longversion==-1 && PyErr_Occurred()) + return NULL; + if ((longversion > USHRT_MAX) || (longversion < 0)) + return PyErr_Format(PyExc_ValueError, "MiniVersion must be in the range 0 - %d", USHRT_MAX); + miniversion=(USHORT)longversion; + pminiversion=&miniversion; + } + if (!PyWinObject_AsWCHAR(obfilename, &filename, FALSE)) + return NULL; + + hret=(*pfnCreateFileTransacted)(filename, desiredaccess, sharemode, psa, creationdisposition, + flags, htemplate, htransaction, pminiversion, extendedparameter); + PyWinObject_FreeWCHAR(filename); + if (hret==INVALID_HANDLE_VALUE) + return PyWin_SetAPIError("CreateFileTransacted"); + return PyWinObject_FromHANDLE(hret); + } + PyCFunction pfnpy_CreateFileTransacted=(PyCFunction)py_CreateFileTransacted; + + // @pyswig |DeleteFileTransacted|Deletes a file as part of a transaction + // @pyseeapi DeleteFileTransacted + // @comm Requires Windows Vista. + // @comm Accepts keyword arguments. + static PyObject *py_DeleteFileTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(DeleteFileTransacted); + WCHAR *filename=NULL; + PyObject *obfilename, *obhtransaction; + HANDLE htransaction; + static char *keywords[]={"FileName","Transaction", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:DeleteFileTransacted", keywords, + &obfilename, // @pyparm <o PyUnicode>|FileName||Name of file to be deleted + &obhtransaction)) // @pyparm <o PyHANDLE>|Transaction||Transaction handle as returned by <om win32transaction.CreateTransaction> + return NULL; + if (!PyWinObject_AsHANDLE(obhtransaction, &htransaction, FALSE)) + return NULL; + if (!PyWinObject_AsWCHAR(obfilename, &filename, FALSE)) + return NULL; + + BOOL ret=(*pfnDeleteFileTransacted)(filename, htransaction); + PyWinObject_FreeWCHAR(filename); + if (!ret) + return PyWin_SetAPIError("DeleteFileTransacted"); + Py_INCREF(Py_None); + return Py_None; + } + PyCFunction pfnpy_DeleteFileTransacted=(PyCFunction)py_DeleteFileTransacted; + + // @pyswig |GetFileAttributesTransacted|Retrieves file attributes as part of a transaction + // @pyseeapi GetFileAttributesTransacted + // @comm Only exists on Windows Vista or later. + // @comm Accepts keyword arguments. Implemented only as Unicode. + // @rdesc Returned info is dependent on the infomation level + static PyObject *py_GetFileAttributesTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + /* ??? This could easily be made part of GetFileAttributesEx, with Transaction as an optional + parameter causing GetFileAttributesTransacted to be called (if available) ??? */ + CHECK_PFN(GetFileAttributesTransacted); + WCHAR *fname=NULL; + PyObject *obfname, *obtrans, *ret=NULL; + GET_FILEEX_INFO_LEVELS lvl=GetFileExInfoStandard; + PVOID buf=NULL; + size_t bufsize; + HANDLE htrans; + static char *keywords[]={"FileName","Transaction","InfoLevelId", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|k:GetFileAttributesTransacted", keywords, + &obfname, // @pyparm <o PyUNICODE>|FileName||File or directory to be moved + &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to the transaction. See <om win32transaction.CreateTransaction>. + &lvl)) // @pyparm int|InfoLevelId|GetFileExInfoStandard|Level of information to return (GET_FILEEX_INFO_LEVELS enum) + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) + return NULL; + switch (lvl){ + // @flagh InfoLevelId|Information returned + // @flag GetFileExInfoStandard|Tuple representing a WIN32_FILE_ATTRIBUTE_DATA struc + case GetFileExInfoStandard: + bufsize = sizeof(WIN32_FILE_ATTRIBUTE_DATA); + break; + default: + return PyErr_Format(PyExc_ValueError, "Level '%d' is not supported", lvl); + } + buf = malloc(bufsize); + if (buf==NULL) + return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); + + if (PyWinObject_AsWCHAR(obfname, &fname, FALSE)){ + // MSDN docs say this returns a DWORD containing the attributes, but it actually acts as a boolean + if (!(*pfnGetFileAttributesTransacted)(fname, lvl, buf, htrans)) + PyWin_SetAPIError("GetFileAttributesTransacted"); + else + ret=PyObject_FromFILEX_INFO(lvl, buf); + } + free(buf); + PyWinObject_FreeWCHAR(fname); + return ret; + } + PyCFunction pfnpy_GetFileAttributesTransacted=(PyCFunction)py_GetFileAttributesTransacted; + + // @pyswig |SetFileAttributesTransacted|Sets a file's attributes as part of a transaction + // @pyseeapi SetFileAttributesTransacted + // @comm Only exists on Windows Vista or later. + // @comm Accepts keyword arguments. Implemented only as Unicode. + static PyObject *py_SetFileAttributesTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(SetFileAttributesTransacted); + WCHAR *fname=NULL; + PyObject *obfname, *obtrans; + DWORD attrs; + HANDLE htrans; + static char *keywords[]={"FileName","FileAttributes","Transaction", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OkO:SetFileAttributesTransacted", keywords, + &obfname, // @pyparm <o PyUNICODE>|FileName||File or directory to be moved + &attrs, // @pyparm int|FileAttributes||Combination of FILE_ATTRIBUTE_* flags + &obtrans)) // @pyparm <o PyHANDLE>|Transaction||Handle to the transaction. See <om win32transaction.CreateTransaction>. + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) + return NULL; + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + BOOL ret=(*pfnSetFileAttributesTransacted)(fname, attrs, htrans); + PyWinObject_FreeWCHAR(fname); + if (!ret) + return PyWin_SetAPIError("SetFileAttributesTransacted"); + Py_INCREF(Py_None); + return Py_None; + } + PyCFunction pfnpy_SetFileAttributesTransacted=(PyCFunction)py_SetFileAttributesTransacted; + + // @pyswig |CreateDirectoryTransacted|Creates a directory as part of a transaction + // @pyseeapi CreateDirectoryTransacted + // @comm Only exists on Windows Vista or later. + // @comm Accepts keyword arguments. Implemented only as Unicode. + static PyObject *py_CreateDirectoryTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(CreateDirectoryTransacted); + WCHAR *dirname=NULL, *templatedir=NULL; + PyObject *obdirname, *obtrans, *obtemplatedir=Py_None, *obsa=Py_None, *ret=NULL; + HANDLE htrans; + SECURITY_ATTRIBUTES *psa; + static char *keywords[]={"NewDirectory","Transaction","TemplateDirectory","SecurityAttributes", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|OO:CreateDirectoryTransacted", keywords, + &obdirname, // @pyparm <o PyUnicode>|NewDirectory||Name of directory to be created + &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to the transaction. See <om win32transaction.CreateTransaction>. + &obtemplatedir, // @pyparm <o PyUnicode>|TemplateDirectory|None|Directory to use as a template + &obsa)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Security for new directory + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) + return NULL; + if (!PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)) + return NULL; + if (PyWinObject_AsWCHAR(obdirname, &dirname, FALSE) + && PyWinObject_AsWCHAR(obtemplatedir, &templatedir, TRUE)){ + if (!(*pfnCreateDirectoryTransacted)(templatedir, dirname, psa, htrans)) + PyWin_SetAPIError("CreateDirectoryTransacted"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PyWinObject_FreeWCHAR(dirname); + PyWinObject_FreeWCHAR(templatedir); + return ret; + } + PyCFunction pfnpy_CreateDirectoryTransacted=(PyCFunction)py_CreateDirectoryTransacted; + + // @pyswig |RemoveDirectoryTransacted|Removes a directory as part of a transaction + // @pyseeapi RemoveDirectoryTransacted + // @comm Only exists on Windows Vista or later. + // @comm Accepts keyword arguments. Implemented only as Unicode. + static PyObject *py_RemoveDirectoryTransacted(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(RemoveDirectoryTransacted); + WCHAR *dirname=NULL; + PyObject *obdirname, *obtrans, *ret=NULL; + HANDLE htrans; + static char *keywords[]={"PathName","Transaction", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:RemoveDirectoryTransacted", keywords, + &obdirname, // @pyparm <o PyUnicode>|PathName||Name of directory to be removed + &obtrans)) // @pyparm <o PyHANDLE>|Transaction||Handle to the transaction. See <om win32transaction.CreateTransaction>. + return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) + return NULL; + if (!PyWinObject_AsWCHAR(obdirname, &dirname, FALSE)) + return NULL; + + if (!(*pfnRemoveDirectoryTransacted)(dirname, htrans)) + PyWin_SetAPIError("RemoveDirectoryTransacted"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + PyWinObject_FreeWCHAR(dirname); + return ret; + } + PyCFunction pfnpy_RemoveDirectoryTransacted=(PyCFunction)py_RemoveDirectoryTransacted; %} + %native (SetVolumeMountPoint) py_SetVolumeMountPoint; %native (DeleteVolumeMountPoint) py_DeleteVolumeMountPoint; ! %native (CreateHardLink) pfnpy_CreateHardLink; ! %native (CreateHardLinkTransacted) pfnpy_CreateHardLinkTransacted; ! %native (CreateSymbolicLink) pfnpy_CreateSymbolicLink; ! %native (CreateSymbolicLinkTransacted) pfnpy_CreateSymbolicLinkTransacted; %native (GetVolumeNameForVolumeMountPoint) py_GetVolumeNameForVolumeMountPoint; %native (GetVolumePathName) py_GetVolumePathName; *************** *** 4112,4117 **** %native (BackupWrite) py_BackupWrite; %native (SetFileShortName) py_SetFileShortName; ! %native (CopyFileEx) py_CopyFileEx; ! %native (MoveFileWithProgress) py_MoveFileWithProgress; %native (ReplaceFile) py_ReplaceFile; %native (OpenEncryptedFileRaw) py_OpenEncryptedFileRaw; --- 4619,4626 ---- %native (BackupWrite) py_BackupWrite; %native (SetFileShortName) py_SetFileShortName; ! %native (CopyFileEx) pfnpy_CopyFileEx; ! %native (CopyFileTransacted) pfnpy_CopyFileTransacted; ! %native (MoveFileWithProgress) pfnpy_MoveFileWithProgress; ! %native (MoveFileTransacted) pfnpy_MoveFileTransacted; %native (ReplaceFile) py_ReplaceFile; %native (OpenEncryptedFileRaw) py_OpenEncryptedFileRaw; *************** *** 4119,4131 **** %native (WriteEncryptedFileRaw) py_WriteEncryptedFileRaw; %native (CloseEncryptedFileRaw) py_CloseEncryptedFileRaw; - %init %{ PyDict_SetItemString(d, "error", PyWinExc_ApiError); HMODULE hmodule; FARPROC fp; ! ! hmodule=LoadLibrary("AdvAPI32.dll"); if (hmodule){ fp=GetProcAddress(hmodule,"EncryptFileW"); --- 4628,4672 ---- %native (WriteEncryptedFileRaw) py_WriteEncryptedFileRaw; %native (CloseEncryptedFileRaw) py_CloseEncryptedFileRaw; + %native (CreateFileTransacted) pfnpy_CreateFileTransacted; + %native (DeleteFileTransacted) pfnpy_DeleteFileTransacted; + %native (GetFileAttributesTransacted) pfnpy_GetFileAttributesTransacted; + %native (SetFileAttributesTransacted) pfnpy_SetFileAttributesTransacted; + %native (CreateDirectoryTransacted) pfnpy_CreateDirectoryTransacted; + %native (RemoveDirectoryTransacted) pfnpy_RemoveDirectoryTransacted; + %init %{ PyDict_SetItemString(d, "error", PyWinExc_ApiError); + PyDict_SetItemString(d, "INVALID_HANDLE_VALUE", PyWinLong_FromHANDLE(INVALID_HANDLE_VALUE)); + + for (PyMethodDef *pmd = win32fileMethods;pmd->ml_name;pmd++) + if ((strcmp(pmd->ml_name, "CreateFileTransacted")==0) + ||(strcmp(pmd->ml_name, "DeleteFileTransacted")==0) + ||(strcmp(pmd->ml_name, "MoveFileWithProgress")==0) + ||(strcmp(pmd->ml_name, "MoveFileTransacted")==0) + ||(strcmp(pmd->ml_name, "CopyFileEx")==0) + ||(strcmp(pmd->ml_name, "CopyFileTransacted")==0) + ||(strcmp(pmd->ml_name, "GetFileAttributesTransacted")==0) + ||(strcmp(pmd->ml_name, "SetFileAttributesTransacted")==0) + ||(strcmp(pmd->ml_name, "CreateHardLink")==0) + ||(strcmp(pmd->ml_name, "CreateHardLinkTransacted")==0) + ||(strcmp(pmd->ml_name, "CreateSymbolicLink")==0) + ||(strcmp(pmd->ml_name, "CreateSymbolicLinkTransacted")==0) + ||(strcmp(pmd->ml_name, "CreateDirectoryTransacted")==0) + ||(strcmp(pmd->ml_name, "RemoveDirectoryTransacted")==0) + ||(strcmp(pmd->ml_name, "FindFirstFileTransacted")==0) // not impl yet + ||(strcmp(pmd->ml_name, "FindFirstStream")==0) // not impl yet + ||(strcmp(pmd->ml_name, "FindFirstStreamTransacted")==0) // not impl yet + ||(strcmp(pmd->ml_name, "GetFullPathNameTransacted")==0) // not impl yet + ||(strcmp(pmd->ml_name, "GetLongPathNameTransacted")==0) // not impl yet + ||(strcmp(pmd->ml_name, "GetFileInformationByHandleEx")==0) // not impl yet + ) + pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; HMODULE hmodule; FARPROC fp; ! hmodule=GetModuleHandle("AdvAPI32.dll"); ! if (hmodule==NULL) ! hmodule=LoadLibrary("AdvAPI32.dll"); if (hmodule){ fp=GetProcAddress(hmodule,"EncryptFileW"); *************** *** 4162,4166 **** } ! hmodule = GetModuleHandle("kernel32.dll"); if (hmodule){ fp = GetProcAddress(hmodule, "GetVolumeNameForVolumeMountPointW"); --- 4703,4709 ---- } ! hmodule=GetModuleHandle("kernel32.dll"); ! if (hmodule==NULL) ! hmodule=LoadLibrary("kernel32.dll"); if (hmodule){ fp = GetProcAddress(hmodule, "GetVolumeNameForVolumeMountPointW"); *************** *** 4176,4182 **** if (fp) pfnDeleteVolumeMountPointW = (BOOL (WINAPI *)(LPCWSTR))(fp); ! fp = GetProcAddress(hmodule, "CreateHardLinkW"); ! if (fp) pfnCreateHardLinkW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES))(fp); ! pfnBackupRead=(BackupReadfunc)GetProcAddress(hmodule,"BackupRead"); pfnBackupSeek=(BackupSeekfunc)GetProcAddress(hmodule,"BackupSeek"); --- 4719,4726 ---- if (fp) pfnDeleteVolumeMountPointW = (BOOL (WINAPI *)(LPCWSTR))(fp); ! pfnCreateHardLink=(CreateHardLinkfunc)GetProcAddress(hmodule, "CreateHardLinkW"); ! pfnCreateHardLinkTransacted=(CreateHardLinkTransactedfunc)GetProcAddress(hmodule, "CreateHardLinkTransactedW"); ! pfnCreateSymbolicLink=(CreateSymbolicLinkfunc)GetProcAddress(hmodule, "CreateSymbolicLinkW"); ! pfnCreateSymbolicLinkTransacted=(CreateSymbolicLinkTransactedfunc)GetProcAddress(hmodule, "CreateSymbolicLinkTransactedW"); pfnBackupRead=(BackupReadfunc)GetProcAddress(hmodule,"BackupRead"); pfnBackupSeek=(BackupSeekfunc)GetProcAddress(hmodule,"BackupSeek"); *************** *** 4184,4190 **** --- 4728,4751 ---- pfnSetFileShortName=(SetFileShortNamefunc)GetProcAddress(hmodule,"SetFileShortNameW"); pfnCopyFileEx=(CopyFileExfunc)GetProcAddress(hmodule,"CopyFileExW"); + pfnCopyFileTransacted=(CopyFileTransactedfunc)GetProcAddress(hmodule, "CopyFileTransactedW"); pfnMoveFileWithProgress=(MoveFileWithProgressfunc)GetProcAddress(hmodule,"MoveFileWithProgressW"); + pfnMoveFileTransacted=(MoveFileTransactedfunc)GetProcAddress(hmodule, "MoveFileTransactedW"); pfnReplaceFile=(ReplaceFilefunc)GetProcAddress(hmodule,"ReplaceFileW"); + pfnCreateFileTransacted=(CreateFileTransactedfunc)GetProcAddress(hmodule, "CreateFileTransactedW"); + pfnDeleteFileTransacted=(DeleteFileTransactedfunc)GetProcAddress(hmodule, "DeleteFileTransactedW"); + pfnGetFileAttributesTransacted=(GetFileAttributesTransactedfunc)GetProcAddress(hmodule, "GetFileAttributesTransactedW"); + pfnSetFileAttributesTransacted=(SetFileAttributesTransactedfunc)GetProcAddress(hmodule, "SetFileAttributesTransactedW"); + pfnCreateDirectoryTransacted=(CreateDirectoryTransactedfunc)GetProcAddress(hmodule, "CreateDirectoryTransactedW"); + pfnRemoveDirectoryTransacted=(RemoveDirectoryTransactedfunc)GetProcAddress(hmodule, "RemoveDirectoryTransactedW"); + // these aren't wrapped yet + pfnFindFirstStream=(FindFirstStreamfunc)GetProcAddress(hmodule, "FindFirstStreamW"); + pfnFindNextStream=(FindNextStreamfunc)GetProcAddress(hmodule, "FindNextStreamW"); + pfnFindFirstStreamTransacted=(FindFirstStreamTransactedfunc)GetProcAddress(hmodule, "FindFirstStreamTransactedW"); + pfnFindFirstFileTransacted=(FindFirstFileTransactedfunc)GetProcAddress(hmodule, "FindFirstFileTransactedW"); + pfnGetFullPathNameTransacted=(GetFullPathNameTransactedfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedW"); + pfnGetLongPathNameTransacted=(GetLongPathNameTransactedfunc)GetProcAddress(hmodule, "GetLongPathNameTransactedW"); + // pfnGetFileInformationByHandleEx=(GetFileInformationByHandleExfunc)GetProcAddress(hmodule, "GetFileInformationByHandleEx"); } + %} *************** *** 4275,4276 **** --- 4836,4840 ---- #define CREATE_FOR_DIR CREATE_FOR_DIR #define OVERWRITE_HIDDEN OVERWRITE_HIDDEN + + // Info level for GetFileAttributesEx and GetFileAttributesTransacted (GET_FILEEX_INFO_LEVELS enum) + #define GetFileExInfoStandard 1 |
From: Roger U. <ru...@us...> - 2007-02-03 21:11:14
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18129 Modified Files: setup.py Log Message: Add win32transaction module Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** setup.py 17 Jan 2007 04:40:56 -0000 1.53 --- setup.py 3 Feb 2007 21:11:13 -0000 1.54 *************** *** 1046,1049 **** --- 1046,1051 ---- ("win32ts", "WtsApi32", True, 0x0501, "win32/src/win32tsmodule.cpp"), ("_win32sysloader", "", False, 0x0501, "win32/src/_win32sysloader.cpp"), + ("win32transaction", "kernel32", True, 0x0501, "win32/src/win32transactionmodule.cpp"), + ): |
From: Roger U. <ru...@us...> - 2007-02-03 21:07:36
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16198/win32/src Added Files: win32transactionmodule.cpp Log Message: New module for the Kernel Transaction Manager functions --- NEW FILE: win32transactionmodule.cpp --- // @doc #include "PyWinTypes.h" #include "PyWinObjects.h" #define CHECK_PFN(fname)if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); typedef HANDLE (WINAPI *CreateTransactionfunc)(LPSECURITY_ATTRIBUTES,LPGUID,DWORD,DWORD,DWORD,DWORD,LPWSTR); static CreateTransactionfunc pfnCreateTransaction=NULL; typedef BOOL (WINAPI *RollbackTransactionfunc)(HANDLE); static RollbackTransactionfunc pfnRollbackTransaction=NULL; typedef BOOL (WINAPI *RollbackTransactionAsyncfunc)(HANDLE); static RollbackTransactionAsyncfunc pfnRollbackTransactionAsync=NULL; typedef BOOL (WINAPI *CommitTransactionfunc)(HANDLE); static CommitTransactionfunc pfnCommitTransaction=NULL; typedef BOOL (WINAPI *CommitTransactionAsyncfunc)(HANDLE); static CommitTransactionAsyncfunc pfnCommitTransactionAsync=NULL; typedef BOOL (WINAPI *GetTransactionIdfunc)(HANDLE,LPGUID); static GetTransactionIdfunc pfnGetTransactionId = NULL; typedef BOOL (WINAPI *GetTransactionInformationfunc)(HANDLE,PDWORD,PDWORD,PDWORD,PDWORD,DWORD,LPWSTR); static GetTransactionInformationfunc pfnGetTransactionInformation = NULL; typedef BOOL (WINAPI *SetTransactionInformationfunc)(HANDLE,DWORD,DWORD,DWORD,LPWSTR); static SetTransactionInformationfunc pfnSetTransactionInformation = NULL; // static char *keywords[]={"TransactionHandle","IsolationLevel","IsolationFlags","Timeout","Description", NULL}; typedef HANDLE (WINAPI *OpenTransactionfunc)(DWORD,LPGUID); static OpenTransactionfunc pfnOpenTransaction = NULL; // static char *keywords[]={"DesiredAccess","TransactionId", NULL}; typedef HANDLE (WINAPI *OpenResourceManagerfunc)(DWORD,HANDLE,LPGUID); static OpenResourceManagerfunc pfnOpenResourceManager = NULL; // static char *keywords[]={"DesiredAccess","TmHandle","RmGuid", NULL}; typedef HANDLE (WINAPI *CreateTransactionManagerfunc)(LPSECURITY_ATTRIBUTES,LPWSTR,ULONG,ULONG); static CreateTransactionManagerfunc pfnCreateTransactionManager = NULL; // static char *keywords[]={"TransactionAttributes","LogFileName","CreateOptions","CommitStrength", NULL}; typedef HANDLE (WINAPI *CreateResourceManagerfunc)(LPSECURITY_ATTRIBUTES,LPGUID,DWORD,HANDLE,LPWSTR); static CreateResourceManagerfunc pfnCreateResourceManager = NULL; // static char *keywords[]={"ResourceManagerAttributes","ResourceManagerID","CreateOptions","TmHandle","Description", NULL}; typedef HANDLE (WINAPI *OpenEnlistmentfunc)(DWORD,HANDLE,LPGUID); static OpenEnlistmentfunc pfnOpenEnlistment = NULL; // static char *keywords[]={"DesiredAccess","ResourceManagerHandle","EnlistmentId", NULL}; typedef HANDLE (WINAPI *CreateEnlistmentfunc)(LPSECURITY_ATTRIBUTES,HANDLE,HANDLE,DWORD,DWORD,PVOID); static CreateEnlistmentfunc pfnCreateEnlistment = NULL; // static char *keywords[]={"EnlistmentrAttributes","ResourceManagerHandle","TransactionHandle","NotificationMask","CreateOptions","EnlistmentKey", NULL}; typedef HANDLE (WINAPI *OpenTransactionManagerfunc)(LPWSTR,ACCESS_MASK,ULONG); static OpenTransactionManagerfunc pfnOpenTransactionManager = NULL; // static char *keywords[]={"LogFileName","DesiredAccess","OpenOptions", NULL}; // @pymethod <o PyHANDLE>|win32transaction|CreateTransaction|Creates a transaction // @pyseeapi CreateTransaction static PyObject *PyCreateTransaction(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(CreateTransaction); WCHAR *description=NULL; PyObject *obsa=Py_None, *obuow=Py_None, *obdescription=Py_None; DWORD createoptions=0, isolationlevel=0, isolationflags=0, timeout=0; PSECURITY_ATTRIBUTES psa=NULL; GUID *uow=NULL; HANDLE hret; static char *keywords[]={"TransactionAttributes","UOW","CreateOptions","IsolationLevel", "IsolationFlags","Timeout","Description", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOkkkkO:CreateTransaction", keywords, &obsa, // @pyparm <o PySECURITY_ATTRIBUTES>|TransactionAttributes|None|Security and inheritance for the transaction, can be None &obuow, // @pyparm <o PyIID>|UOW|None|Reserved, use only None &createoptions, // @pyparm int|CreateOptions|0|TRANSACTION_DO_NOT_PROMOTE is only defined flag &isolationlevel, // @pyparm int|IsolationLevel|0|Reserved, use only 0 &isolationflags, // @pyparm int|IsolationFlags|0|Reserved, use only 0 &timeout, // @pyparm int|Timeout|0|Abort timeout in milliseconds &obdescription)) // @pyparm <o PyUnicode>|Description|None|Text description of transaction, can be None return NULL; if (!PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)) return NULL; if (obuow!=Py_None){ PyErr_SetString(PyExc_TypeError,"UOW must be None"); return NULL; } if (!PyWinObject_AsWCHAR(obdescription, &description, TRUE)) return NULL; Py_BEGIN_ALLOW_THREADS hret=(*pfnCreateTransaction)(psa, uow, createoptions, isolationlevel, isolationflags, timeout, description); Py_END_ALLOW_THREADS PyWinObject_FreeWCHAR(description); if (hret==INVALID_HANDLE_VALUE) return PyWin_SetAPIError("CreateTransaction"); return PyWinObject_FromHANDLE(hret); } // @pymethod |win32transaction|RollbackTransaction|Rolls back a transaction // @pyseeapi RollbackTransaction static PyObject *PyRollbackTransaction(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(RollbackTransaction); PyObject *obtrans; HANDLE htrans; BOOL ret; static char *keywords[]={"TransactionHandle", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:RollbackTransaction", keywords, &obtrans)) // @pyparm <o PyHANDLE>|TransactionHandle||Handle to a transaction return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) return NULL; Py_BEGIN_ALLOW_THREADS ret=(*pfnRollbackTransaction)(htrans); Py_END_ALLOW_THREADS if (!ret) return PyWin_SetAPIError("RollbackTransaction"); Py_INCREF(Py_None); return Py_None; } // @pymethod |win32transaction|RollbackTransactionAsync|Rolls back a transaction asynchronously // @pyseeapi RollbackTransactionAsync static PyObject *PyRollbackTransactionAsync(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(RollbackTransactionAsync); PyObject *obtrans; HANDLE htrans; BOOL ret; static char *keywords[]={"TransactionHandle", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:RollbackTransactionAsync", keywords, &obtrans)) // @pyparm <o PyHANDLE>|TransactionHandle||Handle to a transaction return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) return NULL; Py_BEGIN_ALLOW_THREADS ret=(*pfnRollbackTransactionAsync)(htrans); Py_END_ALLOW_THREADS if (!ret) return PyWin_SetAPIError("RollbackTransactionAsync"); Py_INCREF(Py_None); return Py_None; } // @pymethod |win32transaction|CommitTransaction|Commits a transaction // @pyseeapi CommitTransaction static PyObject *PyCommitTransaction(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(CommitTransaction); PyObject *obtrans; HANDLE htrans; BOOL ret; static char *keywords[]={"TransactionHandle", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:CommitTransaction", keywords, &obtrans)) // @pyparm <o PyHANDLE>|TransactionHandle||Handle to a transaction return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) return NULL; Py_BEGIN_ALLOW_THREADS ret=(*pfnCommitTransaction)(htrans); Py_END_ALLOW_THREADS if (!ret) return PyWin_SetAPIError("CommitTransaction"); Py_INCREF(Py_None); return Py_None; } // @pymethod |win32transaction|CommitTransactionAsync|Commits a transaction asynchronously // @pyseeapi CommitTransactionAsync static PyObject *PyCommitTransactionAsync(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(CommitTransactionAsync); PyObject *obtrans; HANDLE htrans; BOOL ret; static char *keywords[]={"TransactionHandle", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:CommitTransactionAsync", keywords, &obtrans)) // @pyparm <o PyHANDLE>|TransactionHandle||Handle to a transaction return NULL; if (!PyWinObject_AsHANDLE(obtrans, &htrans, FALSE)) return NULL; Py_BEGIN_ALLOW_THREADS ret=(*pfnCommitTransactionAsync)(htrans); Py_END_ALLOW_THREADS if (!ret) return PyWin_SetAPIError("CommitTransactionAsync"); Py_INCREF(Py_None); return Py_None; } // @module win32transaction|Module wrapping Kernal Transaction Manager functions, as used with // transacted NTFS and transacted registry functions. // @comm These functions are only available on Vista and later. // @comm All functions accept keyword arguments. static PyMethodDef win32transaction_functions[] = { // @pymeth CreateTransaction|Creates a transaction { "CreateTransaction", (PyCFunction)PyCreateTransaction, METH_KEYWORDS|METH_VARARGS}, // @pymeth RollbackTransaction|Rolls back a transaction { "RollbackTransaction", (PyCFunction)PyRollbackTransaction, METH_KEYWORDS|METH_VARARGS}, // @pymeth RollbackTransactionAsync|Rolls back a transaction asynchronously { "RollbackTransactionAsync", (PyCFunction)PyRollbackTransactionAsync, METH_KEYWORDS|METH_VARARGS}, // @pymeth CommitTransaction|Commits a transaction { "CommitTransaction", (PyCFunction)PyCommitTransaction, METH_KEYWORDS|METH_VARARGS}, // @pymeth CommitTransactionAsync|Commits a transaction asynchronously { "CommitTransactionAsync", (PyCFunction)PyCommitTransactionAsync, METH_KEYWORDS|METH_VARARGS}, { NULL, NULL } }; extern "C" __declspec(dllexport) void initwin32transaction(void) { PyObject *dict, *mod; PyWinGlobals_Ensure(); mod = Py_InitModule("win32transaction", win32transaction_functions); // Load dll and function pointers to avoid dependency on newer libraries and headers HMODULE hmodule=GetModuleHandle(L"Ktmw32.dll"); if (hmodule==NULL) hmodule=LoadLibrary(L"Ktmw32.dll"); if (hmodule){ pfnCreateTransaction=(CreateTransactionfunc)GetProcAddress(hmodule, "CreateTransaction"); pfnRollbackTransaction=(RollbackTransactionfunc)GetProcAddress(hmodule, "RollbackTransaction"); pfnRollbackTransactionAsync=(RollbackTransactionAsyncfunc)GetProcAddress(hmodule, "RollbackTransactionAsync"); pfnCommitTransaction=(CommitTransactionfunc)GetProcAddress(hmodule, "CommitTransaction"); pfnCommitTransactionAsync=(CommitTransactionAsyncfunc)GetProcAddress(hmodule, "CommitTransactionAsync"); pfnGetTransactionId=(GetTransactionIdfunc)GetProcAddress(hmodule, "GetTransactionId"); pfnGetTransactionInformation=(GetTransactionInformationfunc)GetProcAddress(hmodule, "GetTransactionInformation"); pfnSetTransactionInformation=(SetTransactionInformationfunc)GetProcAddress(hmodule, "SetTransactionInformation"); pfnOpenTransaction=(OpenTransactionfunc)GetProcAddress(hmodule, "OpenTransaction"); pfnOpenResourceManager=(OpenResourceManagerfunc)GetProcAddress(hmodule, "OpenResourceManager"); pfnCreateTransactionManager=(CreateTransactionManagerfunc)GetProcAddress(hmodule, "CreateTransactionManager"); pfnCreateResourceManager=(CreateResourceManagerfunc)GetProcAddress(hmodule, "CreateResourceManager"); pfnOpenEnlistment=(OpenEnlistmentfunc)GetProcAddress(hmodule, "OpenEnlistment"); pfnCreateEnlistment=(CreateEnlistmentfunc)GetProcAddress(hmodule, "CreateEnlistment"); pfnOpenTransactionManager=(OpenTransactionManagerfunc)GetProcAddress(hmodule, "OpenTransactionManager"); } dict = PyModule_GetDict(mod); Py_INCREF(PyWinExc_ApiError); PyDict_SetItemString(dict, "error", PyWinExc_ApiError); } /* Transaction access rights used with OpenTransaction: TRANSACTION_QUERY_INFORMATION TRANSACTION_SET_INFORMATION TRANSACTION_ENLIST TRANSACTION_COMMIT TRANSACTION_ROLLBACK TRANSACTION_GENERIC_READ TRANSACTION_GENERIC_WRITE TRANSACTION_GENERIC_EXECUTE TRANSACTION_ALL_ACCESS TRANSACTION_RESOURCE_MANAGER_RIGHTS TRANSACTION_PROPAGATE */ /* Transaction manager access rights used with OpenTransactionManager TRANSACTIONMANAGER_QUERY_INFORMATION TRANSACTIONMANAGER_SET_INFORMATION TRANSACTIONMANAGER_RECOVER TRANSACTIONMANAGER_RENAME TRANSACTIONMANAGER_CREATE_RM TRANSACTIONMANAGER_GENERIC_READ TRANSACTIONMANAGER_GENERIC_WRITE TRANSACTIONMANAGER_GENERIC_EXECUTE TRANSACTIONMANAGER_ALL_ACCESS */ /* Resource manager rights: RESOURCEMANAGER_QUERY_INFORMATION RESOURCEMANAGER_SET_INFORMATION RESOURCEMANAGER_RECOVER RESOURCEMANAGER_ENLIST RESOURCEMANAGER_GET_NOTIFICATION RESOURCEMANAGER_GENERIC_READ RESOURCEMANAGER_GENERIC_WRITE RESOURCEMANAGER_GENERIC_EXECUTE RESOURCEMANAGER_ALL_ACCESS */ /* NOTIFICATION_MASK enum: TRANSACTION_NOTIFY_MASK TRANSACTION_NOTIFY_PREPREPARE TRANSACTION_NOTIFY_PREPARE TRANSACTION_NOTIFY_COMMIT TRANSACTION_NOTIFY_ROLLBACK TRANSACTION_NOTIFY_PREPREPARE_COMPLETE TRANSACTION_NOTIFY_PREPARE_COMPLETE TRANSACTION_NOTIFY_COMMIT_COMPLETE TRANSACTION_NOTIFY_ROLLBACK_COMPLETE TRANSACTION_NOTIFY_RECOVER TRANSACTION_NOTIFY_SINGLE_PHASE_COMMIT TRANSACTION_NOTIFY_DELEGATE_COMMIT TRANSACTION_NOTIFY_RECOVER_QUERY TRANSACTION_NOTIFY_ENLIST_PREPREPARE TRANSACTION_NOTIFY_LAST_RECOVER TRANSACTION_NOTIFY_INDOUBT TRANSACTION_NOTIFY_TM_ONLINE TRANSACTION_NOTIFY_REQUEST_OUTCOME */ |
From: Mark H. <mha...@us...> - 2007-01-30 22:36:02
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20980 Modified Files: pyscript.py Log Message: Support the threading model "both" Index: pyscript.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/pyscript.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pyscript.py 11 Apr 2005 13:04:40 -0000 1.9 --- pyscript.py 30 Jan 2007 22:35:57 -0000 1.10 *************** *** 212,216 **** _reg_class_spec_ = "win32com.axscript.client.pyscript.PyScript" _reg_remove_keys_ = [(".pys",), ("pysFile",)] ! _reg_threading_ = "Apartment" def __init__(self): --- 212,216 ---- _reg_class_spec_ = "win32com.axscript.client.pyscript.PyScript" _reg_remove_keys_ = [(".pys",), ("pysFile",)] ! _reg_threading_ = "both" def __init__(self): |
From: Roger U. <ru...@us...> - 2007-01-27 20:09:24
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5923/com/win32comext/shell/src Modified Files: PyIShellBrowser.cpp Log Message: 64-bit compat for make_param function Index: PyIShellBrowser.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellBrowser.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyIShellBrowser.cpp 22 Jan 2007 21:18:58 -0000 1.6 --- PyIShellBrowser.cpp 27 Jan 2007 20:09:20 -0000 1.7 *************** *** 262,293 **** // 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; } --- 262,295 ---- // Little helper stolen from win32gui ! // Need to change win32gui also, or move this function into pywintypes ! static BOOL make_param(PyObject *ob, WPARAM *pparam) { ! if (ob==NULL || ob==Py_None){ ! *pparam=NULL; ! return TRUE; ! } #ifdef UNICODE #define TCHAR_DESC "Unicode" ! if (PyUnicode_Check(ob)){ ! *pparam = (WPARAM)PyUnicode_AS_UNICODE(ob); ! return TRUE; ! } #else #define TCHAR_DESC "String" ! if (PyString_Check(ob)){ ! *pparam = (WPARAM)PyString_AS_STRING(ob); ! return TRUE; } ! #endif ! *pparam=(WPARAM)PyLong_AsVoidPtr(ob); ! if ((*pparam!=NULL) || !PyErr_Occurred()) ! return TRUE; ! ! PyErr_Clear(); ! PyBufferProcs *pb = ob->ob_type->tp_as_buffer; ! if (pb != NULL && pb->bf_getreadbuffer) ! return pb->bf_getreadbuffer(ob,0,(VOID **)pparam)!=-1; ! PyErr_SetString(PyExc_TypeError, "Must be a" TCHAR_DESC ", int, or buffer object"); ! return FALSE; } *************** *** 309,315 **** WPARAM wParam; LPARAM lParam; ! if (!make_param(obwparam, (long *)&wParam)) return NULL; ! if (!make_param(oblparam, (long *)&lParam)) return NULL; --- 311,318 ---- WPARAM wParam; LPARAM lParam; ! if (!make_param(obwparam, &wParam)) return NULL; ! // WPARAM and LPARAM are defined as UINT_PTR and LONG_PTR, so they can't be used interchangeably without a cast ! if (!make_param(oblparam, (WPARAM *)&lParam)) return NULL; *************** *** 321,325 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); ! return PyInt_FromLong(ret); } --- 324,329 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); ! // LRESULT is defined as LONG_PTR. This should work for either 32 or 64 bit. ! return PyLong_FromLongLong(ret); } |
From: Roger U. <ru...@us...> - 2007-01-27 17:18:31
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5903/com/win32comext/shell/src Modified Files: PyIShellView.cpp Log Message: Fix place where HWND treated as a long Index: PyIShellView.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellView.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyIShellView.cpp 26 Jan 2005 22:31:09 -0000 1.5 --- PyIShellView.cpp 27 Jan 2007 17:18:28 -0000 1.6 *************** *** 144,148 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISV, IID_IShellView ); ! return PyLong_FromVoidPtr(hWnd); } --- 144,148 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISV, IID_IShellView ); ! return PyWinLong_FromHANDLE(hWnd); } *************** *** 388,393 **** if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! if (PyInt_Check(result) || PyLong_Check(result)) ! *phWnd = (HWND)PyInt_AsLong(result); Py_DECREF(result); return hr; --- 388,393 ---- if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! if (!PyWinObject_AsHANDLE(result, (HANDLE *)phWnd, TRUE)) ! hr=MAKE_PYCOM_GATEWAY_FAILURE_CODE("CreateViewWindow"); Py_DECREF(result); return hr; |
From: Roger U. <ru...@us...> - 2007-01-25 21:42:21
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18945/win32/src Modified Files: win32process.i Log Message: Couple more 64-bit compatibility changes Index: win32process.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** win32process.i 25 Jan 2007 04:59:44 -0000 1.25 --- win32process.i 25 Jan 2007 21:42:17 -0000 1.26 *************** *** 63,67 **** typedef DWORD (WINAPI *SetThreadIdealProcessorfunc)(HANDLE, DWORD); static SetThreadIdealProcessorfunc pfnSetThreadIdealProcessor = NULL; ! typedef DWORD (WINAPI *SetProcessAffinityMaskfunc)(HANDLE, DWORD); static SetProcessAffinityMaskfunc pfnSetProcessAffinityMask = NULL; #endif --- 63,67 ---- typedef DWORD (WINAPI *SetThreadIdealProcessorfunc)(HANDLE, DWORD); static SetThreadIdealProcessorfunc pfnSetThreadIdealProcessor = NULL; ! typedef DWORD (WINAPI *SetProcessAffinityMaskfunc)(HANDLE, DWORD_PTR); static SetProcessAffinityMaskfunc pfnSetProcessAffinityMask = NULL; #endif *************** *** 754,757 **** --- 754,768 ---- #endif // MS_WINCE + %{ + // GetCurrentProcess returns -1 which is INVALID_HANDLE_VALUE, so can't use swig typemap for HANDLE + // @pyswig int|GetCurrentProcess|Retrieves a pseudo handle for the current process. + static PyObject *MyGetCurrentProcess(PyObject *self, PyObject *args) + { + if(!PyArg_ParseTuple(args,":GetCurrentProcess")) + return NULL; + return PyWinLong_FromHANDLE(GetCurrentProcess()); + } + %} + %native (GetCurrentProcess) MyGetCurrentProcess; // @pyswig int|GetProcessVersion|Obtains the major and minor version numbers of the system on which a specified process expects to run. *************** *** 760,766 **** ); - // @pyswig int|GetCurrentProcess|Retrieves a pseudo handle for the current process. - DWORD GetCurrentProcess(); - // @pyswig int|GetCurrentProcessId|Retrieves the process identifier of the calling process. DWORD GetCurrentProcessId(); --- 771,774 ---- |
From: Roger U. <ru...@us...> - 2007-01-25 04:59:45
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17040/win32/src Modified Files: win32process.i Log Message: VC6 doesn't recognize uintptr_t Index: win32process.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** win32process.i 25 Jan 2007 04:17:42 -0000 1.24 --- win32process.i 25 Jan 2007 04:59:44 -0000 1.25 *************** *** 389,393 **** PyEval_InitThreads(); PythonThreadData *ptd = new PythonThreadData(obFunc, obArgs); ! uintptr_t handle; unsigned tid; handle = _beginthreadex((void *)pSA, stackSize, ThreadEntryPoint, ptd, flags, &tid); --- 389,393 ---- PyEval_InitThreads(); PythonThreadData *ptd = new PythonThreadData(obFunc, obArgs); ! ULONG_PTR handle; unsigned tid; handle = _beginthreadex((void *)pSA, stackSize, ThreadEntryPoint, ptd, flags, &tid); |
From: Roger U. <ru...@us...> - 2007-01-25 04:17:46
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1254/win32/src Modified Files: win32process.i Log Message: Various changes for 64-bit compatibility (HANDLE's and SIZE_T's) _beginthreadex returns null on failure Standardize loading of function pointers Index: win32process.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** win32process.i 16 Jan 2007 19:04:21 -0000 1.23 --- win32process.i 25 Jan 2007 04:17:42 -0000 1.24 *************** *** 19,32 **** #define CHECK_PFN(fname)if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); - static BOOL (WINAPI *fpEnumProcesses)(DWORD *, DWORD, DWORD *) = NULL; - static BOOL (WINAPI *fpEnumProcessModules)(HANDLE, HMODULE *, DWORD, LPDWORD) = NULL; - static DWORD (WINAPI *fpGetModuleFileNameEx)(HANDLE, HMODULE, WCHAR *, DWORD) = NULL; - #ifndef MS_WINCE - static BOOL (WINAPI *fpGetProcessMemoryInfo)(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD) = NULL; - static BOOL (WINAPI *fpGetProcessTimes)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME) = NULL; - static BOOL (WINAPI *fpGetProcessIoCounters)(HANDLE, PIO_COUNTERS) = NULL; - static BOOL (WINAPI *fpGetProcessShutdownParameters)(LPDWORD, LPDWORD) = NULL; - static BOOL (WINAPI *fpSetProcessShutdownParameters)(DWORD, DWORD) = NULL; typedef BOOL (WINAPI *GetProcessWorkingSetSizefunc)(HANDLE, PSIZE_T, PSIZE_T); static GetProcessWorkingSetSizefunc pfnGetProcessWorkingSetSize = NULL; --- 19,41 ---- #define CHECK_PFN(fname)if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); + typedef BOOL (WINAPI *EnumProcessesfunc)(DWORD *, DWORD, DWORD *); + static EnumProcessesfunc pfnEnumProcesses = NULL; + typedef BOOL (WINAPI *EnumProcessModulesfunc)(HANDLE, HMODULE *, DWORD, LPDWORD); + static EnumProcessModulesfunc pfnEnumProcessModules = NULL; + typedef DWORD (WINAPI *GetModuleFileNameExfunc)(HANDLE, HMODULE, WCHAR *, DWORD); + static GetModuleFileNameExfunc pfnGetModuleFileNameEx = NULL; + + #ifndef MS_WINCE + typedef BOOL (WINAPI *GetProcessMemoryInfofunc)(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD); + static GetProcessMemoryInfofunc pfnGetProcessMemoryInfo=NULL; + typedef BOOL (WINAPI *GetProcessTimesfunc)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME); + static GetProcessTimesfunc pfnGetProcessTimes = NULL; + typedef BOOL (WINAPI *GetProcessIoCountersfunc)(HANDLE, PIO_COUNTERS); + static GetProcessIoCountersfunc pfnGetProcessIoCounters = NULL; + typedef BOOL (WINAPI *GetProcessShutdownParametersfunc)(LPDWORD, LPDWORD); + static GetProcessShutdownParametersfunc pfnGetProcessShutdownParameters = NULL; + typedef BOOL (WINAPI *SetProcessShutdownParametersfunc)(DWORD, DWORD); + static SetProcessShutdownParametersfunc pfnSetProcessShutdownParameters = NULL; typedef BOOL (WINAPI *GetProcessWorkingSetSizefunc)(HANDLE, PSIZE_T, PSIZE_T); static GetProcessWorkingSetSizefunc pfnGetProcessWorkingSetSize = NULL; *************** *** 50,53 **** --- 59,68 ---- typedef BOOL (WINAPI *GetThreadTimesfunc)(HANDLE,LPFILETIME,LPFILETIME,LPFILETIME,LPFILETIME); static GetThreadTimesfunc pfnGetThreadTimes = NULL; + typedef HANDLE (WINAPI *CreateRemoteThreadfunc)(HANDLE, LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD); + static CreateRemoteThreadfunc pfnCreateRemoteThread=NULL; + typedef DWORD (WINAPI *SetThreadIdealProcessorfunc)(HANDLE, DWORD); + static SetThreadIdealProcessorfunc pfnSetThreadIdealProcessor = NULL; + typedef DWORD (WINAPI *SetProcessAffinityMaskfunc)(HANDLE, DWORD); + static SetProcessAffinityMaskfunc pfnSetProcessAffinityMask = NULL; #endif *************** *** 154,158 **** return obHandle; } ! return PyInt_FromLong((long)h); } --- 169,173 ---- return obHandle; } ! return PyWinLong_FromHANDLE(h); } *************** *** 186,208 **** int sethandle(PyObject **pobHandle, HANDLE *ph, PyObject *v) { ! int rc = 0; Py_XDECREF(*pobHandle); ! *pobHandle = NULL; ! *ph = NULL; ! if (v==Py_None) ! ; // Do nothing! ! else if (PyHANDLE_Check(v)) { *pobHandle = v; ! if (PyWinObject_AsHANDLE(v, ph)) ! Py_INCREF(v); ! else ! rc = -1; ! } else if (PyInt_Check(v)) { ! *ph = (HANDLE)PyInt_AsLong(v); ! } else { ! PyErr_SetString(PyExc_TypeError, "Invalid object type for HANDLE"); ! rc = -1; ! } ! return rc; } --- 201,216 ---- int sethandle(PyObject **pobHandle, HANDLE *ph, PyObject *v) { ! HANDLE htmp; ! if (!PyWinObject_AsHANDLE(v, &htmp, TRUE)) ! return -1; ! *ph=htmp; Py_XDECREF(*pobHandle); ! if (PyHANDLE_Check(v)){ *pobHandle = v; ! Py_INCREF(v); ! } ! else ! *pobHandle = NULL; ! return 0; } *************** *** 360,369 **** PyObject *obFunc, *obArgs, *obSA; unsigned stackSize, flags; ! if (!PyArg_ParseTuple(args, "OiOOi", &obSA, // @pyparm <o PySECURITY_ATTRIBUTES>|sa||The security attributes, or None &stackSize, // @pyparm int|stackSize||Stack size for the new thread, or zero for the default size. &obFunc, // @pyparm function|entryPoint||The thread function. &obArgs, // @pyparm tuple|args||Args passed to the function. ! &flags)) // @pyparm int|flags|| return NULL; if (!PyCallable_Check(obFunc)) { --- 368,377 ---- PyObject *obFunc, *obArgs, *obSA; unsigned stackSize, flags; ! if (!PyArg_ParseTuple(args, "OiOOi:beginthreadex", &obSA, // @pyparm <o PySECURITY_ATTRIBUTES>|sa||The security attributes, or None &stackSize, // @pyparm int|stackSize||Stack size for the new thread, or zero for the default size. &obFunc, // @pyparm function|entryPoint||The thread function. &obArgs, // @pyparm tuple|args||Args passed to the function. ! &flags)) // @pyparm int|flags||Can be CREATE_SUSPENDED so thread doesn't run immediately return NULL; if (!PyCallable_Check(obFunc)) { *************** *** 381,400 **** PyEval_InitThreads(); PythonThreadData *ptd = new PythonThreadData(obFunc, obArgs); ! unsigned long handle; unsigned tid; handle = _beginthreadex((void *)pSA, stackSize, ThreadEntryPoint, ptd, flags, &tid); ! if (handle==-1) { delete ptd; ! PyErr_SetFromErrno(PyExc_RuntimeError); ! } ! // @comm The result is a tuple of the thread handle and thread ID. ! PyObject *obHandle = PyWinObject_FromHANDLE((HANDLE)handle); ! PyObject *rc = Py_BuildValue("Oi", obHandle, tid); ! Py_DECREF(obHandle); ! return rc; } - %} - %native (beginthreadex) mybeginthreadex; --- 389,403 ---- PyEval_InitThreads(); PythonThreadData *ptd = new PythonThreadData(obFunc, obArgs); ! uintptr_t handle; unsigned tid; handle = _beginthreadex((void *)pSA, stackSize, ThreadEntryPoint, ptd, flags, &tid); ! if (handle==-1 || handle==NULL){ delete ptd; ! return PyErr_SetFromErrno(PyExc_RuntimeError); ! } ! // @rdesc The result is a tuple of the thread handle and thread ID. ! return Py_BuildValue("Ni", PyWinObject_FromHANDLE((HANDLE)handle), tid); } %} %native (beginthreadex) mybeginthreadex; *************** *** 404,457 **** static PyObject *myCreateRemoteThread(PyObject *self, PyObject *args) { ! PyObject *obFunc, *obArgs, *obSA; ! unsigned stackSize, flags; ! int hprocess; ! if (!PyArg_ParseTuple(args, "iOiOOi", ! &hprocess, // @pyparm int|hprocess||The handle to the remote process. &obSA, // @pyparm <o PySECURITY_ATTRIBUTES>|sa||The security attributes, or None &stackSize, // @pyparm int|stackSize||Stack size for the new thread, or zero for the default size. &obFunc, // @pyparm function|entryPoint||The thread function's address. ! &obArgs, // @pyparm tuple|args||Args passed to the function. &flags)) // @pyparm int|flags|| return NULL; ! if (!PyInt_Check(obFunc)) { ! PyErr_SetString(PyExc_TypeError, "function must be an address"); return NULL; ! } ! if (!PyInt_Check(obArgs)) { ! PyErr_SetString(PyExc_TypeError, "args must be an address"); return NULL; - } SECURITY_ATTRIBUTES *pSA; if (!PyWinObject_AsSECURITY_ATTRIBUTES( obSA, &pSA, TRUE )) return NULL; - HANDLE (WINAPI *pfnCreateRemoteThread)( HANDLE, LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD) = NULL; - HMODULE hmod = GetModuleHandle("kernel32.dll"); - if (hmod) - pfnCreateRemoteThread = (HANDLE (WINAPI *)( HANDLE, LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD)) - GetProcAddress(hmod, "CreateRemoteThread"); - if (pfnCreateRemoteThread==NULL) - return PyWin_SetAPIError("CreateRemoteThread", E_NOTIMPL); - PyEval_InitThreads(); HANDLE handle; DWORD tid; ! handle = (*pfnCreateRemoteThread)((HANDLE)hprocess, pSA, stackSize, ! (LPTHREAD_START_ROUTINE )PyLong_AsVoidPtr(obFunc), ! PyLong_AsVoidPtr(obArgs), flags, &tid); ! if (handle==(HANDLE)-1 || handle==(HANDLE)0) { return PyWin_SetAPIError("CreateRemoteThread"); } ! // @comm The result is a tuple of the thread handle and thread ID. ! PyObject *obHandle = PyWinObject_FromHANDLE((HANDLE)handle); ! PyObject *rc = Py_BuildValue("Oi", obHandle, tid); ! Py_DECREF(obHandle); ! return rc; } - %} - %native (CreateRemoteThread) myCreateRemoteThread; --- 407,456 ---- static PyObject *myCreateRemoteThread(PyObject *self, PyObject *args) { ! CHECK_PFN(CreateRemoteThread); ! #ifdef _WIN64 ! static char *fmt="OOLOOk:CreateRemoteThread"; ! #else ! static char *fmt="OOlOOk:CreateRemoteThread"; ! #endif ! ! PyObject *obhprocess, *obFunc, *obParameter, *obSA; ! SIZE_T stackSize; ! DWORD flags; ! HANDLE hprocess; ! LPTHREAD_START_ROUTINE Func; ! VOID *Parameter; ! if (!PyArg_ParseTuple(args, fmt, ! &obhprocess, // @pyparm <o PyHANDLE>|hprocess||The handle to the remote process. &obSA, // @pyparm <o PySECURITY_ATTRIBUTES>|sa||The security attributes, or None &stackSize, // @pyparm int|stackSize||Stack size for the new thread, or zero for the default size. &obFunc, // @pyparm function|entryPoint||The thread function's address. ! &obParameter, // @pyparm int|Parameter||Arg passed to the function in the form of a void pointer &flags)) // @pyparm int|flags|| return NULL; ! if (!PyWinObject_AsHANDLE(obhprocess, &hprocess, FALSE)) return NULL; ! Func=(LPTHREAD_START_ROUTINE)PyLong_AsVoidPtr(obFunc); ! if (Func==NULL && PyErr_Occurred()) ! return NULL; ! Parameter=PyLong_AsVoidPtr(obParameter); ! if (Parameter==NULL && PyErr_Occurred()) return NULL; SECURITY_ATTRIBUTES *pSA; if (!PyWinObject_AsSECURITY_ATTRIBUTES( obSA, &pSA, TRUE )) return NULL; PyEval_InitThreads(); HANDLE handle; DWORD tid; ! handle = (*pfnCreateRemoteThread)(hprocess, pSA, stackSize, ! Func, Parameter, flags, &tid); ! if (handle==INVALID_HANDLE_VALUE || handle==NULL) { return PyWin_SetAPIError("CreateRemoteThread"); } ! // @rdesc The result is a tuple of the thread handle and thread ID. ! return Py_BuildValue("Ni", PyWinObject_FromHANDLE(handle), tid); } %} %native (CreateRemoteThread) myCreateRemoteThread; *************** *** 756,769 **** - #ifndef MS_WINCE - // @pyswig int, int|GetProcessAffinityMask|Gets a processor affinity mask for a specified thread. - // @rdesc The result is a tuple of (process affinity mask, system affinity mask) - BOOLAPI GetProcessAffinityMask( - HANDLE hProcess, // @pyparm <o PyHANDLE>|hProcess||handle to the process of interest - DWORD *OUTPUT, // lpProcessAffinityMask - DWORD *OUTPUT // lpSystemAffinityMask - ); - #endif // MS_WINCE - // @pyswig int|GetProcessVersion|Obtains the major and minor version numbers of the system on which a specified process expects to run. DWORD GetProcessVersion( --- 755,758 ---- *************** *** 953,962 **** ); - // @pyswig int|SetThreadAffinityMask|Sets a processor affinity mask for a specified thread. - DWORD SetThreadAffinityMask ( - HANDLE hThread, // @pyparm <o PyHANDLE>|handle||handle to the thread of interest - DWORD dwThreadAffinityMask // @pyparm int|mask||a thread affinity mask - ); - // @pyswig |AttachThreadInput|Attaches or detaches the input of two threads BOOLAPI AttachThreadInput( --- 942,945 ---- *************** *** 970,983 **** static PyObject *MySetThreadIdealProcessor( HANDLE hThread, DWORD dwIdealProc ) { ! DWORD (WINAPI *pfnSetThreadIdealProcessor)( HANDLE hThread, DWORD dwIdealProc ) = NULL; ! HMODULE hmod = GetModuleHandle("kernel32.dll"); ! if (hmod) ! pfnSetThreadIdealProcessor = (DWORD (WINAPI *)( HANDLE hThread, DWORD dwIdealProc )) ! GetProcAddress(hmod, "SetThreadIdealProcessor"); ! if (pfnSetThreadIdealProcessor==NULL) ! return PyWin_SetAPIError("SetThreadIdealProcessor", E_NOTIMPL); DWORD rc = (*pfnSetThreadIdealProcessor)(hThread, dwIdealProc); if (rc==-1) ! return PyWin_SetAPIError("SetThreadIdealProcessor", E_NOTIMPL); return PyInt_FromLong(rc); } --- 953,960 ---- static PyObject *MySetThreadIdealProcessor( HANDLE hThread, DWORD dwIdealProc ) { ! CHECK_PFN(SetThreadIdealProcessor); DWORD rc = (*pfnSetThreadIdealProcessor)(hThread, dwIdealProc); if (rc==-1) ! return PyWin_SetAPIError("SetThreadIdealProcessor"); return PyInt_FromLong(rc); } *************** *** 992,1009 **** %{ // Appears to be some problem with the optimizer here, so I just leave it off! #pragma optimize ("", off) ! // This function does not exist on all platforms. ! static PyObject *MySetProcessAffinityMask( HANDLE hThread, DWORD dwMask ) { ! DWORD (WINAPI *pfnSetProcessAffinityMask)( HANDLE hThread, DWORD dwMask ) = NULL; ! HMODULE hmod = GetModuleHandle("kernel32.dll"); ! if (hmod) ! pfnSetProcessAffinityMask = (DWORD (WINAPI *)( HANDLE hThread, DWORD dwMask )) ! GetProcAddress(hmod, "SetProcessAffinityMask"); ! if (pfnSetProcessAffinityMask==NULL) ! return PyWin_SetAPIError("SetProcessAffinityMask", E_NOTIMPL); ! BOOL ok = (*pfnSetProcessAffinityMask)(hThread, dwMask); ! if (!ok) return PyWin_SetAPIError("SetProcessAffinityMask"); Py_INCREF(Py_None); --- 969,1014 ---- %{ + // @pyswig int, int|GetProcessAffinityMask|Gets a processor affinity mask for a specified process + // @rdesc The result is a tuple of (process affinity mask, system affinity mask) + static PyObject *MyGetProcessAffinityMask(PyObject *self, PyObject *args) + { + HANDLE hProcess; + PyObject *obhProcess; + DWORD_PTR processmask, systemmask; + if (!PyArg_ParseTuple(args, "O:GetProcessAffinityMask", + &obhProcess)) // @pyparm <o PyHANDLE>|hProcess||handle to the process of interest + return NULL; + if (!PyWinObject_AsHANDLE(obhProcess, &hProcess, FALSE)) + return NULL; + if (!GetProcessAffinityMask(hProcess, &processmask, &systemmask)) + return PyWin_SetAPIError("GetProcessAffinityMask"); + return Py_BuildValue("NN", + PyLong_FromUnsignedLongLong(processmask), + PyLong_FromUnsignedLongLong(systemmask)); + } + // Appears to be some problem with the optimizer here, so I just leave it off! #pragma optimize ("", off) ! // @pyswig |SetProcessAffinityMask|Sets a processor affinity mask for a specified process. ! // @comm This function does not exist on all platforms. ! static PyObject *MySetProcessAffinityMask(PyObject *self, PyObject *args) { ! CHECK_PFN(SetProcessAffinityMask); ! DWORD_PTR dwMask; ! HANDLE hProcess; ! PyObject *obhProcess; ! // Mask is 64 bits on win64 ! #ifdef _WIN64 ! static char *fmt="OK:SetProcessAffinityMask"; ! #else ! static char *fmt="Ok:SetProcessAffinityMask"; ! #endif ! if (!PyArg_ParseTuple(args, fmt, ! &obhProcess, // @pyparm <o PyHANDLE>|hProcess||handle to the process of interest ! &dwMask)) // @pyparm int|mask||a processor affinity mask ! return NULL; ! if (!PyWinObject_AsHANDLE(obhProcess, &hProcess, FALSE)) ! return NULL; ! if (!(*pfnSetProcessAffinityMask)(hProcess, dwMask)) return PyWin_SetAPIError("SetProcessAffinityMask"); Py_INCREF(Py_None); *************** *** 1011,1023 **** } #pragma optimize ("", on) - %} - - // @pyswig |SetProcessAffinityMask|Sets a processor affinity mask for a specified process. - %name(SetProcessAffinityMask) - PyObject *MySetProcessAffinityMask ( - HANDLE hThread, // @pyparm <o PyHANDLE>|handle||handle to the process of interest - DWORD dwThreadAffinityMask // @pyparm int|mask||a thread affinity mask - ); #endif // MS_WINCE --- 1016,1047 ---- } #pragma optimize ("", on) + // @pyswig int|SetThreadAffinityMask|Sets a processor affinity mask for a specified thread. + static PyObject *MySetThreadAffinityMask(PyObject *self, PyObject *args) + { + DWORD_PTR dwMask, prevMask; + HANDLE hThread; + PyObject *obhThread; + // Mask is 64 bits on win64 + #ifdef _WIN64 + static char *fmt="OK:SetThreadAffinityMask"; + #else + static char *fmt="Ok:SetThreadAffinityMask"; + #endif + if (!PyArg_ParseTuple(args, fmt, + &obhThread, // @pyparm <o PyHANDLE>|hThread||handle to the thread of interest + &dwMask)) // @pyparm int|ThreadAffinityMask||a processor affinity mask + return NULL; + if (!PyWinObject_AsHANDLE(obhThread, &hThread, FALSE)) + return NULL; + prevMask=SetThreadAffinityMask(hThread, dwMask); + if (prevMask==0) + return PyWin_SetAPIError("SetThreadAffinityMask"); + return PyLong_FromUnsignedLongLong(prevMask); + } + %} + %native(GetProcessAffinityMask) MyGetProcessAffinityMask; + %native(SetProcessAffinityMask) MySetProcessAffinityMask; + %native(SetThreadAffinityMask) MySetThreadAffinityMask; #endif // MS_WINCE *************** *** 1071,1079 **** PyObject *PyEnumProcesses(PyObject *self, PyObject *args) { ! if (fpEnumProcesses==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"EnumProcesses does not exist on this platform"); ! return NULL; ! } ! DWORD *pids=NULL, *pid=NULL; DWORD nbr_pids_allocated=100, nbr_pids_returned=0, tuple_ind=0; --- 1095,1099 ---- PyObject *PyEnumProcesses(PyObject *self, PyObject *args) { ! CHECK_PFN(EnumProcesses); DWORD *pids=NULL, *pid=NULL; DWORD nbr_pids_allocated=100, nbr_pids_returned=0, tuple_ind=0; *************** *** 1095,1099 **** return NULL; } ! if (!(*fpEnumProcesses)(pids, bytes_allocated, &bytes_returned)){ PyWin_SetAPIError("EnumProcesses",GetLastError()); goto done; --- 1115,1119 ---- return NULL; } ! if (!(*pfnEnumProcesses)(pids, bytes_allocated, &bytes_returned)){ PyWin_SetAPIError("EnumProcesses",GetLastError()); goto done; *************** *** 1131,1148 **** PyObject *PyEnumProcessModules(PyObject *self, PyObject *args) { ! if (fpEnumProcessModules==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"EnumProcessModules does not exist on this platform"); ! return NULL; ! } ! HMODULE *hmods=NULL, *hmod=NULL; HANDLE hprocess=NULL; DWORD nbr_hmods_allocated=100, nbr_hmods_returned=0, tuple_ind=0; DWORD bytes_allocated=0,bytes_needed=0; ! PyObject *ret=NULL, *obhmod=NULL; // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! if (!PyArg_ParseTuple(args, "l:EnumProcessModules", &hprocess)) return NULL; - bytes_allocated=nbr_hmods_allocated*sizeof(HMODULE); do{ --- 1151,1165 ---- PyObject *PyEnumProcessModules(PyObject *self, PyObject *args) { ! CHECK_PFN(EnumProcessModules); HMODULE *hmods=NULL, *hmod=NULL; HANDLE hprocess=NULL; DWORD nbr_hmods_allocated=100, nbr_hmods_returned=0, tuple_ind=0; DWORD bytes_allocated=0,bytes_needed=0; ! PyObject *ret=NULL, *obhmod=NULL, *obhprocess; // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! if (!PyArg_ParseTuple(args, "O:EnumProcessModules", &obhprocess)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhprocess, &hprocess, FALSE)) return NULL; bytes_allocated=nbr_hmods_allocated*sizeof(HMODULE); do{ *************** *** 1156,1160 **** return NULL; } ! if (!(*fpEnumProcessModules)(hprocess, hmods, bytes_allocated, &bytes_needed)){ PyWin_SetAPIError("EnumProcessModules",GetLastError()); goto done; --- 1173,1177 ---- return NULL; } ! if (!(*pfnEnumProcessModules)(hprocess, hmods, bytes_allocated, &bytes_needed)){ PyWin_SetAPIError("EnumProcessModules",GetLastError()); goto done; *************** *** 1171,1175 **** hmod=hmods; for (tuple_ind=0;tuple_ind<nbr_hmods_returned;tuple_ind++){ ! obhmod=Py_BuildValue("l",*hmod); if (obhmod==NULL){ Py_DECREF(ret); --- 1188,1192 ---- hmod=hmods; for (tuple_ind=0;tuple_ind<nbr_hmods_returned;tuple_ind++){ ! obhmod=PyWinLong_FromHANDLE(*hmod); if (obhmod==NULL){ Py_DECREF(ret); *************** *** 1177,1181 **** goto done; } ! PyTuple_SetItem(ret,tuple_ind,obhmod); hmod++; } --- 1194,1198 ---- goto done; } ! PyTuple_SET_ITEM(ret,tuple_ind,obhmod); hmod++; } *************** *** 1192,1199 **** PyObject *PyGetModuleFileNameEx(PyObject *self, PyObject *args) { ! if (fpGetModuleFileNameEx==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"GetModuleFileNameEx does not exist on this platform"); ! return NULL; ! } WCHAR *fname=NULL; DWORD chars_allocated=256, chars_returned=0; --- 1209,1213 ---- PyObject *PyGetModuleFileNameEx(PyObject *self, PyObject *args) { ! CHECK_PFN(GetModuleFileNameEx); WCHAR *fname=NULL; DWORD chars_allocated=256, chars_returned=0; *************** *** 1201,1208 **** HMODULE hmod; HANDLE hprocess; ! PyObject *ret=NULL; // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! // @pyparm int|hModule||Module handle ! if (!PyArg_ParseTuple(args, "ll:GetModuleFileNameEx", &hprocess, &hmod)) return NULL; --- 1215,1226 ---- HMODULE hmod; HANDLE hprocess; ! PyObject *ret=NULL, *obhprocess, *obhmod; // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! // @pyparm <o PyHANDLE>|hModule||Module handle ! if (!PyArg_ParseTuple(args, "OO:GetModuleFileNameEx", &obhprocess, &obhmod)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhprocess, &hprocess, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhmod, (HANDLE *)&hmod, FALSE)) return NULL; *************** *** 1217,1221 **** return NULL; } ! chars_returned=(*fpGetModuleFileNameEx)(hprocess, hmod, fname, chars_allocated); if (!chars_returned){ PyWin_SetAPIError("GetModuleFileNameEx",GetLastError()); --- 1235,1239 ---- return NULL; } ! chars_returned=(*pfnGetModuleFileNameEx)(hprocess, hmod, fname, chars_allocated); if (!chars_returned){ PyWin_SetAPIError("GetModuleFileNameEx",GetLastError()); *************** *** 1239,1247 **** PyObject *PyGetProcessMemoryInfo(PyObject *self, PyObject *args) { ! if (fpGetProcessMemoryInfo==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"GetProcessMemoryInfo does not exist on this platform"); ! return NULL; ! } HANDLE hProcess; PROCESS_MEMORY_COUNTERS pmc; DWORD cb=sizeof(PROCESS_MEMORY_COUNTERS); --- 1257,1263 ---- PyObject *PyGetProcessMemoryInfo(PyObject *self, PyObject *args) { ! CHECK_PFN(GetProcessMemoryInfo); HANDLE hProcess; + PyObject *obhProcess; PROCESS_MEMORY_COUNTERS pmc; DWORD cb=sizeof(PROCESS_MEMORY_COUNTERS); *************** *** 1249,1268 **** // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! if (!PyArg_ParseTuple(args, "l:GetProcessMemoryInfo", &hProcess)) return NULL; ! if (!(*fpGetProcessMemoryInfo)(hProcess, &pmc, cb)){ PyWin_SetAPIError("GetProcessMemoryInfo",GetLastError()); return NULL; } ! return Py_BuildValue("{s:l,s:l,s:l,s:l,s:l,s:l,s:l,s:l,s:l}", ! "PageFaultCount",pmc.PageFaultCount, ! "PeakWorkingSetSize",pmc.PeakWorkingSetSize, ! "WorkingSetSize",pmc.WorkingSetSize, ! "QuotaPeakPagedPoolUsage",pmc.QuotaPeakPagedPoolUsage, ! "QuotaPagedPoolUsage",pmc.QuotaPagedPoolUsage, ! "QuotaPeakNonPagedPoolUsage",pmc.QuotaPeakNonPagedPoolUsage, ! "QuotaNonPagedPoolUsage",pmc.QuotaNonPagedPoolUsage, ! "PagefileUsage",pmc.PagefileUsage, ! "PeakPagefileUsage",pmc.PeakPagefileUsage); } %} --- 1265,1287 ---- // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! if (!PyArg_ParseTuple(args, "O:GetProcessMemoryInfo", &obhProcess)) return NULL; ! if (!PyWinObject_AsHANDLE(obhProcess, &hProcess, FALSE)) ! return NULL; ! ! if (!(*pfnGetProcessMemoryInfo)(hProcess, &pmc, cb)){ PyWin_SetAPIError("GetProcessMemoryInfo",GetLastError()); return NULL; } ! return Py_BuildValue("{s:k,s:N,s:N,s:N,s:N,s:N,s:N,s:N,s:N}", ! "PageFaultCount", pmc.PageFaultCount, ! "PeakWorkingSetSize", PyLong_FromUnsignedLongLong(pmc.PeakWorkingSetSize), ! "WorkingSetSize", PyLong_FromUnsignedLongLong(pmc.WorkingSetSize), ! "QuotaPeakPagedPoolUsage", PyLong_FromUnsignedLongLong(pmc.QuotaPeakPagedPoolUsage), ! "QuotaPagedPoolUsage", PyLong_FromUnsignedLongLong(pmc.QuotaPagedPoolUsage), ! "QuotaPeakNonPagedPoolUsage", PyLong_FromUnsignedLongLong(pmc.QuotaPeakNonPagedPoolUsage), ! "QuotaNonPagedPoolUsage", PyLong_FromUnsignedLongLong(pmc.QuotaNonPagedPoolUsage), ! "PagefileUsage", PyLong_FromUnsignedLongLong(pmc.PagefileUsage), ! "PeakPagefileUsage", PyLong_FromUnsignedLongLong(pmc.PeakPagefileUsage)); } %} *************** *** 1273,1287 **** PyObject *PyGetProcessTimes(PyObject *self, PyObject *args) { ! if (fpGetProcessTimes==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"GetProcessTimes does not exist on this platform"); ! return NULL; ! } HANDLE hProcess; FILETIME CreationTime, ExitTime, KernelTime, UserTime; ULARGE_INTEGER ulKernelTime, ulUserTime; // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! if (!PyArg_ParseTuple(args, "l:GetProcessTimes", &hProcess)) return NULL; ! if (!(*fpGetProcessTimes)(hProcess, &CreationTime, &ExitTime, &KernelTime, &UserTime)){ PyWin_SetAPIError("GetProcessTimes",GetLastError()); return NULL; --- 1292,1307 ---- PyObject *PyGetProcessTimes(PyObject *self, PyObject *args) { ! CHECK_PFN(GetProcessTimes); HANDLE hProcess; + PyObject *obhProcess; FILETIME CreationTime, ExitTime, KernelTime, UserTime; ULARGE_INTEGER ulKernelTime, ulUserTime; // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! if (!PyArg_ParseTuple(args, "O:GetProcessTimes", &obhProcess)) return NULL; ! if (!PyWinObject_AsHANDLE(obhProcess, &hProcess, FALSE)) ! return NULL; ! ! if (!(*pfnGetProcessTimes)(hProcess, &CreationTime, &ExitTime, &KernelTime, &UserTime)){ PyWin_SetAPIError("GetProcessTimes",GetLastError()); return NULL; *************** *** 1302,1315 **** PyObject *PyGetProcessIoCounters(PyObject *self, PyObject *args) { ! if (fpGetProcessIoCounters==NULL){ ! PyErr_SetString(PyExc_NotImplementedError,"GetProcessIoCounters does not exist on this platform"); ! return NULL; ! } HANDLE hProcess; IO_COUNTERS ioc; // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! if (!PyArg_ParseTuple(args, "l:GetProcessIoCounters", &hProcess)) return NULL; ! if (!(*fpGetProcessIoCounters)(hProcess, &ioc)){ PyWin_SetAPIError("GetProcessIoCounters",GetLastError()); return NULL; --- 1322,1335 ---- PyObject *PyGetProcessIoCounters(PyObject *self, PyObject *args) { ! CHECK_PFN(GetProcessIoCounters); HANDLE hProcess; + PyObject *obhProcess; IO_COUNTERS ioc; // @pyparm <o PyHANDLE>|hProcess||Process handle as returned by OpenProcess ! if (!PyArg_ParseTuple(args, "O:GetProcessIoCounters", &obhProcess)) return NULL; ! if (!PyWinObject_AsHANDLE(obhProcess, &hProcess, FALSE)) ! return NULL; ! if (!(*pfnGetProcessIoCounters)(hProcess, &ioc)){ PyWin_SetAPIError("GetProcessIoCounters",GetLastError()); return NULL; *************** *** 1393,1404 **** PyObject *PyGetProcessShutdownParameters(PyObject *self, PyObject *args) { DWORD Level=0, Flags=0; - if (fpGetProcessShutdownParameters==NULL){ - PyErr_SetString(PyExc_NotImplementedError,"GetProcessShutdownParameters does not exist on this platform"); - return NULL; - } if (!PyArg_ParseTuple(args, ":GetProcessShutdownParameters")) return NULL; ! if (!(*fpGetProcessShutdownParameters)(&Level, &Flags)){ PyWin_SetAPIError("GetProcessShutdownParameters",GetLastError()); return NULL; --- 1413,1421 ---- PyObject *PyGetProcessShutdownParameters(PyObject *self, PyObject *args) { + CHECK_PFN(GetProcessShutdownParameters); DWORD Level=0, Flags=0; if (!PyArg_ParseTuple(args, ":GetProcessShutdownParameters")) return NULL; ! if (!(*pfnGetProcessShutdownParameters)(&Level, &Flags)){ PyWin_SetAPIError("GetProcessShutdownParameters",GetLastError()); return NULL; *************** *** 1414,1427 **** PyObject *PySetProcessShutdownParameters(PyObject *self, PyObject *args) { DWORD Level=0, Flags=0; - if (fpSetProcessShutdownParameters==NULL){ - PyErr_SetString(PyExc_NotImplementedError,"SetProcessShutdownParameters does not exist on this platform"); - return NULL; - } // @pyparm int|Level||Priority, higher means earlier // @pyparm int|Flags||Currently only SHUTDOWN_NORETRY valid if (!PyArg_ParseTuple(args, "ll:SetProcessShutdownParameters", &Level, &Flags)) return NULL; ! if (!(*fpSetProcessShutdownParameters)(Level, Flags)){ PyWin_SetAPIError("SetProcessShutdownParameters",GetLastError()); return NULL; --- 1431,1441 ---- PyObject *PySetProcessShutdownParameters(PyObject *self, PyObject *args) { + CHECK_PFN(SetProcessShutdownParameters); DWORD Level=0, Flags=0; // @pyparm int|Level||Priority, higher means earlier // @pyparm int|Flags||Currently only SHUTDOWN_NORETRY valid if (!PyArg_ParseTuple(args, "ll:SetProcessShutdownParameters", &Level, &Flags)) return NULL; ! if (!(*pfnSetProcessShutdownParameters)(Level, Flags)){ PyWin_SetAPIError("SetProcessShutdownParameters",GetLastError()); return NULL; *************** *** 1465,1481 **** hmodule=LoadLibrary(_T("Psapi.dll")); if (hmodule!=NULL){ ! fp=GetProcAddress(hmodule, _T("EnumProcesses")); ! if (fp!=NULL) ! fpEnumProcesses=(BOOL (WINAPI *)(DWORD *, DWORD, DWORD *))(fp); ! fp=GetProcAddress(hmodule, _T("EnumProcessModules")); ! if (fp!=NULL) ! fpEnumProcessModules=(BOOL (WINAPI *)(HANDLE, HMODULE *, DWORD, LPDWORD))(fp); ! fp=GetProcAddress(hmodule, _T("GetModuleFileNameExW")); ! if (fp!=NULL) ! fpGetModuleFileNameEx=(DWORD (WINAPI *)(HANDLE, HMODULE, WCHAR *, DWORD))(fp); #ifndef MS_WINCE ! fp=GetProcAddress(hmodule,_T("GetProcessMemoryInfo")); ! if (fp!=NULL) ! fpGetProcessMemoryInfo=(BOOL (WINAPI *)(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD))(fp); #endif } --- 1479,1487 ---- hmodule=LoadLibrary(_T("Psapi.dll")); if (hmodule!=NULL){ ! pfnEnumProcesses = (EnumProcessesfunc)GetProcAddress(hmodule, _T("EnumProcesses")); ! pfnEnumProcessModules = (EnumProcessModulesfunc)GetProcAddress(hmodule, _T("EnumProcessModules")); ! pfnGetModuleFileNameEx = (GetModuleFileNameExfunc)GetProcAddress(hmodule, _T("GetModuleFileNameExW")); #ifndef MS_WINCE ! pfnGetProcessMemoryInfo = (GetProcessMemoryInfofunc)GetProcAddress(hmodule, _T("GetProcessMemoryInfo")); #endif } *************** *** 1486,1502 **** hmodule=LoadLibrary(_T("Kernel32.dll")); if (hmodule!=NULL){ ! fp=GetProcAddress(hmodule, "GetProcessTimes"); ! if (fp!=NULL) ! fpGetProcessTimes=(BOOL (WINAPI *)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME))(fp); ! fp=GetProcAddress(hmodule, "GetProcessIoCounters"); ! if (fp!=NULL) ! fpGetProcessIoCounters=(BOOL (WINAPI *)(HANDLE, PIO_COUNTERS))(fp); ! fp=GetProcAddress(hmodule, "GetProcessShutdownParameters"); ! if (fp!=NULL) ! fpGetProcessShutdownParameters=(BOOL (WINAPI *)(LPDWORD, LPDWORD))(fp); ! fp=GetProcAddress(hmodule, "SetProcessShutdownParameters"); ! if (fp!=NULL) ! fpSetProcessShutdownParameters=(BOOL (WINAPI *)(DWORD, DWORD))(fp); ! pfnGetProcessWorkingSetSize=(GetProcessWorkingSetSizefunc)GetProcAddress(hmodule,"GetProcessWorkingSetSize"); pfnSetProcessWorkingSetSize=(SetProcessWorkingSetSizefunc)GetProcAddress(hmodule,"SetProcessWorkingSetSize"); --- 1492,1499 ---- hmodule=LoadLibrary(_T("Kernel32.dll")); if (hmodule!=NULL){ ! pfnGetProcessTimes=(GetProcessTimesfunc)GetProcAddress(hmodule,"GetProcessTimes"); ! pfnGetProcessIoCounters=(GetProcessIoCountersfunc)GetProcAddress(hmodule,"GetProcessIoCounters"); ! pfnGetProcessShutdownParameters=(GetProcessShutdownParametersfunc)GetProcAddress(hmodule,"GetProcessShutdownParameters"); ! pfnSetProcessShutdownParameters=(SetProcessShutdownParametersfunc)GetProcAddress(hmodule,"SetProcessShutdownParameters"); pfnGetProcessWorkingSetSize=(GetProcessWorkingSetSizefunc)GetProcAddress(hmodule,"GetProcessWorkingSetSize"); pfnSetProcessWorkingSetSize=(SetProcessWorkingSetSizefunc)GetProcAddress(hmodule,"SetProcessWorkingSetSize"); *************** *** 1507,1510 **** --- 1504,1510 ---- pfnGetThreadIOPendingFlag=(GetThreadIOPendingFlagfunc)GetProcAddress(hmodule,"GetThreadIOPendingFlag"); pfnGetThreadTimes=(GetThreadTimesfunc)GetProcAddress(hmodule,"GetThreadTimes"); + pfnCreateRemoteThread=(CreateRemoteThreadfunc)GetProcAddress(hmodule,"CreateRemoteThread"); + pfnSetThreadIdealProcessor=(SetThreadIdealProcessorfunc)GetProcAddress(hmodule,"SetThreadIdealProcessor"); + pfnSetProcessAffinityMask=(SetProcessAffinityMaskfunc)GetProcAddress(hmodule,"SetProcessAffinityMask"); } |
From: Mark H. <mha...@us...> - 2007-01-22 22:18:49
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29112 Modified Files: gencache.py Log Message: Correct the way we were looking for .py files on the filesystem Index: gencache.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/gencache.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** gencache.py 13 Feb 2005 12:05:46 -0000 1.31 --- gencache.py 22 Jan 2007 22:18:44 -0000 1.32 *************** *** 606,610 **** ret = [] for file in files: ! if not os.path.isdir(file) and not os.path.splitext(file)==".py": continue name = os.path.splitext(os.path.split(file)[1])[0] --- 606,610 ---- ret = [] for file in files: ! if not os.path.isdir(file) and not os.path.splitext(file)[1]==".py": continue name = os.path.splitext(os.path.split(file)[1])[0] |
From: Roger U. <ru...@us...> - 2007-01-22 21:19:03
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6151/com/win32comext/shell/src Modified Files: PyIShellBrowser.cpp Log Message: Change places where handles treated as ints or longs Use "I" format for UINTS Index: PyIShellBrowser.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellBrowser.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyIShellBrowser.cpp 12 Jun 2004 13:28:15 -0000 1.5 --- PyIShellBrowser.cpp 22 Jan 2007 21:18:58 -0000 1.6 *************** *** 32,36 **** } ! // @pymethod |PyIShellBrowser|InsertMenusSB|Description of InsertMenusSB. PyObject *PyIShellBrowser::InsertMenusSB(PyObject *self, PyObject *args) { --- 32,36 ---- } ! // @pymethod <o PyLPOLEMENUGROUPWIDTHS>|PyIShellBrowser|InsertMenusSB|Updates a composite menu with container's options PyObject *PyIShellBrowser::InsertMenusSB(PyObject *self, PyObject *args) { *************** *** 38,53 **** if ( pISB == NULL ) return NULL; - // @pyparm int|hmenuShared||Description for hmenuShared OLEMENUGROUPWIDTHS menuWidths; ! PyObject *obMenuWidths; ! // @pyparm <o PyLPOLEMENUGROUPWIDTHS>|lpMenuWidths||Description for lpMenuWidths ! INT ihmenuShared; HMENU hmenuShared; ! if ( !PyArg_ParseTuple(args, "iO:InsertMenusSB", &ihmenuShared, &obMenuWidths) ) return NULL; - BOOL bPythonIsHappy = TRUE; - hmenuShared = (HMENU)ihmenuShared; - if (bPythonIsHappy && !PyObject_AsOLEMENUGROUPWIDTHS( obMenuWidths, &menuWidths )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; --- 38,52 ---- if ( pISB == NULL ) return NULL; OLEMENUGROUPWIDTHS menuWidths; ! PyObject *obMenuWidths, *obhmenuShared; HMENU hmenuShared; ! if ( !PyArg_ParseTuple(args, "OO:InsertMenusSB", ! &obhmenuShared, // @pyparm <o PyHANDLE>|hmenuShared||Newly created menu that contains no items ! &obMenuWidths)) // @pyparm <o PyLPOLEMENUGROUPWIDTHS>|lpMenuWidths||Tuple of 6 ints. Items 0,2,and 4 are updated when the tuple is returned. ! return NULL; ! if (!PyWinObject_AsHANDLE(obhmenuShared, (HANDLE *)&hmenuShared, FALSE)) ! return NULL; ! if (!PyObject_AsOLEMENUGROUPWIDTHS( obMenuWidths, &menuWidths)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; *************** *** 59,63 **** } ! // @pymethod |PyIShellBrowser|SetMenuSB|Description of SetMenuSB. PyObject *PyIShellBrowser::SetMenuSB(PyObject *self, PyObject *args) { --- 58,62 ---- } ! // @pymethod |PyIShellBrowser|SetMenuSB|Attaches a shared menu to a shell view window PyObject *PyIShellBrowser::SetMenuSB(PyObject *self, PyObject *args) { *************** *** 65,86 **** if ( pISB == NULL ) return NULL; - // @pyparm int|hmenuShared||Description for hmenuShared - // @pyparm int|holemenuRes||Description for holemenuRes - // @pyparm HWND|hwndActiveObject||Description for hwndActiveObject - INT ihmenuShared; - INT iholemenuRes; HMENU hmenuShared; HOLEMENU holemenuRes; HWND hwndActiveObject; ! if ( !PyArg_ParseTuple(args, "iil:SetMenuSB", &ihmenuShared, &iholemenuRes, &hwndActiveObject) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! hmenuShared = (HMENU)ihmenuShared; ! holemenuRes = (HOLEMENU)iholemenuRes; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->SetMenuSB( hmenuShared, holemenuRes, hwndActiveObject ); - PY_INTERFACE_POSTCALL; --- 64,86 ---- if ( pISB == NULL ) return NULL; HMENU hmenuShared; HOLEMENU holemenuRes; HWND hwndActiveObject; ! PyObject *obhmenuShared, *obholemenuRes, *obhwndActiveObject; ! if (!PyArg_ParseTuple(args, "OOO:SetMenuSB", ! &obhmenuShared, // @pyparm <o PyHANDLE>|hmenuShared||Handle to the shared menu ! &obholemenuRes, // @pyparm <o PyHANDLE>|holemenuRes||Reserved, use only None (or 0) ! &obhwndActiveObject)) // @pyparm <o PyHANDLE>|hwndActiveObject||Handle to the shell window return NULL; ! if (!PyWinObject_AsHANDLE(obhmenuShared, (HANDLE *)&hmenuShared, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obholemenuRes, (HANDLE *)&holemenuRes, TRUE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwndActiveObject, (HANDLE *)&hwndActiveObject, FALSE)) ! return NULL; ! HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->SetMenuSB( hmenuShared, holemenuRes, hwndActiveObject ); PY_INTERFACE_POSTCALL; *************** *** 92,96 **** } ! // @pymethod |PyIShellBrowser|RemoveMenusSB|Description of RemoveMenusSB. PyObject *PyIShellBrowser::RemoveMenusSB(PyObject *self, PyObject *args) { --- 92,96 ---- } ! // @pymethod |PyIShellBrowser|RemoveMenusSB|Asks container to remove any items it added to a composite menu PyObject *PyIShellBrowser::RemoveMenusSB(PyObject *self, PyObject *args) { *************** *** 98,109 **** if ( pISB == NULL ) return NULL; ! // @pyparm int|hmenuShared||Description for hmenuShared ! INT ihmenuShared; HMENU hmenuShared; ! if ( !PyArg_ParseTuple(args, "i:RemoveMenusSB", &ihmenuShared) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! hmenuShared = (HMENU)ihmenuShared; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; --- 98,109 ---- if ( pISB == NULL ) return NULL; ! PyObject *obhmenuShared; HMENU hmenuShared; ! if (!PyArg_ParseTuple(args, "O:RemoveMenusSB", ! &obhmenuShared)) // @pyparm <o PyHANDLE>|hmenuShared||Handle to the composite menu return NULL; ! if (!PyWinObject_AsHANDLE(obhmenuShared, (HANDLE *)&hmenuShared, FALSE)) ! return NULL; ! HRESULT hr; PY_INTERFACE_PRECALL; *************** *** 119,123 **** } ! // @pymethod |PyIShellBrowser|SetStatusTextSB|Description of SetStatusTextSB. PyObject *PyIShellBrowser::SetStatusTextSB(PyObject *self, PyObject *args) { --- 119,123 ---- } ! // @pymethod |PyIShellBrowser|SetStatusTextSB|Sets the status text in view's status bar PyObject *PyIShellBrowser::SetStatusTextSB(PyObject *self, PyObject *args) { *************** *** 125,136 **** if ( pISB == NULL ) return NULL; - // @pyparm <o unicode>|pszStatusText||Description for pszStatusText PyObject *obpszStatusText; LPOLESTR pszStatusText; ! if ( !PyArg_ParseTuple(args, "O:SetStatusTextSB", &obpszStatusText) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyWinObject_AsBstr(obpszStatusText, &pszStatusText)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; --- 125,135 ---- if ( pISB == NULL ) return NULL; PyObject *obpszStatusText; LPOLESTR pszStatusText; ! if (!PyArg_ParseTuple(args, "O:SetStatusTextSB", ! &obpszStatusText)) // @pyparm <o PyUnicode>|pszStatusText||New status to be displayed ! return NULL; ! if (!PyWinObject_AsBstr(obpszStatusText, &pszStatusText)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; *************** *** 147,151 **** } ! // @pymethod |PyIShellBrowser|EnableModelessSB|Description of EnableModelessSB. PyObject *PyIShellBrowser::EnableModelessSB(PyObject *self, PyObject *args) { --- 146,150 ---- } ! // @pymethod |PyIShellBrowser|EnableModelessSB|Enables or disables modeless dialogs PyObject *PyIShellBrowser::EnableModelessSB(PyObject *self, PyObject *args) { *************** *** 153,159 **** if ( pISB == NULL ) return NULL; - // @pyparm int|fEnable||Description for fEnable BOOL fEnable; ! if ( !PyArg_ParseTuple(args, "i:EnableModelessSB", &fEnable) ) return NULL; HRESULT hr; --- 152,158 ---- if ( pISB == NULL ) return NULL; BOOL fEnable; ! if (!PyArg_ParseTuple(args, "i:EnableModelessSB", ! &fEnable)) // @pyparm boolean|fEnable||Use True to enable or False to disable modeless dialog boxes return NULL; HRESULT hr; *************** *** 170,174 **** } ! // @pymethod |PyIShellBrowser|TranslateAcceleratorSB|Description of TranslateAcceleratorSB. PyObject *PyIShellBrowser::TranslateAcceleratorSB(PyObject *self, PyObject *args) { --- 169,173 ---- } ! // @pymethod |PyIShellBrowser|TranslateAcceleratorSB|Translates keystrokes used as menu item activators PyObject *PyIShellBrowser::TranslateAcceleratorSB(PyObject *self, PyObject *args) { *************** *** 176,193 **** if ( pISB == NULL ) return NULL; - // *** The input argument pmsg of type "MSG *" was not processed *** - // Please check the conversion function is appropriate and exists! MSG msg; PyObject *obpmsg; - // @pyparm <o PyMSG>|pmsg||Description for pmsg - // @pyparm int|wID||Description for wID - INT iwID; WORD wID; ! if ( !PyArg_ParseTuple(args, "Oi:TranslateAcceleratorSB", &obpmsg, &iwID) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyObject_AsMSG( obpmsg, &msg )) bPythonIsHappy = FALSE; ! wID = iwID; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; --- 175,188 ---- if ( pISB == NULL ) return NULL; MSG msg; PyObject *obpmsg; WORD wID; ! if (!PyArg_ParseTuple(args, "OH:TranslateAcceleratorSB", ! &obpmsg, // @pyparm <o PyMSG>|pmsg||Keystroke message to be translated ! &wID)) // @pyparm int|wID||Menu command id for the keystroke return NULL; ! if (!PyObject_AsMSG(obpmsg, &msg)) ! return NULL; ! HRESULT hr; PY_INTERFACE_PRECALL; *************** *** 200,204 **** } ! // @pymethod |PyIShellBrowser|BrowseObject|Description of BrowseObject. PyObject *PyIShellBrowser::BrowseObject(PyObject *self, PyObject *args) { --- 195,199 ---- } ! // @pymethod |PyIShellBrowser|BrowseObject|Navigates to a different location PyObject *PyIShellBrowser::BrowseObject(PyObject *self, PyObject *args) { *************** *** 206,219 **** if ( pISB == NULL ) return NULL; - // @pyparm <o PyIDL>|pidl||Description for pidl - // @pyparm int|wFlags||Description for wFlags PyObject *obpidl; LPITEMIDLIST pidl; UINT wFlags; ! if ( !PyArg_ParseTuple(args, "Oi:BrowseObject", &obpidl, &wFlags) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyObject_AsPIDL(obpidl, &pidl, FALSE)) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; --- 201,213 ---- if ( pISB == NULL ) return NULL; PyObject *obpidl; LPITEMIDLIST pidl; UINT wFlags; ! if ( !PyArg_ParseTuple(args, "OI:BrowseObject", ! &obpidl, // @pyparm <o PyIDL>|pidl||Item id list that specifies the new browse location, can be None ! &wFlags)) // @pyparm int|wFlags||Combination of shellcon.SBSP_* flags ! return NULL; ! if (!PyObject_AsPIDL(obpidl, &pidl, TRUE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; *************** *** 227,231 **** } ! // @pymethod |PyIShellBrowser|GetViewStateStream|Description of GetViewStateStream. PyObject *PyIShellBrowser::GetViewStateStream(PyObject *self, PyObject *args) { --- 221,225 ---- } ! // @pymethod <o PyIStream>|PyIShellBrowser|GetViewStateStream|Returns a stream that can be used to access view state information PyObject *PyIShellBrowser::GetViewStateStream(PyObject *self, PyObject *args) { *************** *** 233,237 **** if ( pISB == NULL ) return NULL; ! // @pyparm int|grfMode||Description for grfMode DWORD grfMode; IStream * ppStrm; --- 227,231 ---- if ( pISB == NULL ) return NULL; ! // @pyparm int|grfMode||Read/write mode, one of STGM_READ,STGM_WRITE,STGM_READWRITE DWORD grfMode; IStream * ppStrm; *************** *** 247,251 **** } ! // @pymethod |PyIShellBrowser|GetControlWindow|Description of GetControlWindow. PyObject *PyIShellBrowser::GetControlWindow(PyObject *self, PyObject *args) { --- 241,245 ---- } ! // @pymethod |PyIShellBrowser|GetControlWindow|Returns a handle to one of the browser's control elements PyObject *PyIShellBrowser::GetControlWindow(PyObject *self, PyObject *args) { *************** *** 253,259 **** if ( pISB == NULL ) return NULL; ! // @pyparm int|id||Description for id UINT id; ! if ( !PyArg_ParseTuple(args, "i:GetControlWindow", &id) ) return NULL; HWND hwnd; --- 247,253 ---- if ( pISB == NULL ) return NULL; ! // @pyparm int|id||One of shellcon.FCW_* values UINT id; ! if ( !PyArg_ParseTuple(args, "I:GetControlWindow", &id) ) return NULL; HWND hwnd; *************** *** 264,268 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); ! return PyLong_FromVoidPtr(hwnd); } --- 258,262 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); ! return PyWinLong_FromHANDLE(hwnd); } *************** *** 298,302 **** } ! // @pymethod |PyIShellBrowser|SendControlMsg|Description of SendControlMsg. PyObject *PyIShellBrowser::SendControlMsg(PyObject *self, PyObject *args) { --- 292,296 ---- } ! // @pymethod int|PyIShellBrowser|SendControlMsg|Sends a control msg to browser's toolbar or status bar PyObject *PyIShellBrowser::SendControlMsg(PyObject *self, PyObject *args) { *************** *** 304,315 **** if ( pISB == NULL ) return NULL; ! // @pyparm int|id||Description for id ! // @pyparm int|uMsg||Description for uMsg ! // @pyparm int|wParam||Description for wParam ! // @pyparm long|lParam||Description for lParam UINT id; UINT uMsg; PyObject *obwparam, *oblparam; ! if ( !PyArg_ParseTuple(args, "iiOO:SendControlMsg", &id, &uMsg, &obwparam, &oblparam) ) return NULL; WPARAM wParam; --- 298,309 ---- if ( pISB == NULL ) return NULL; ! // @pyparm int|id||shellcon.FCW_TOOLBAR or FCW_STATUS ! // @pyparm int|uMsg||The message to send ! // @pyparm int|wParam||Value is dependent on the message ! // @pyparm long|lParam||Value is dependent on the message UINT id; UINT uMsg; PyObject *obwparam, *oblparam; ! if ( !PyArg_ParseTuple(args, "IIOO:SendControlMsg", &id, &uMsg, &obwparam, &oblparam) ) return NULL; WPARAM wParam; *************** *** 330,334 **** } ! // @pymethod |PyIShellBrowser|QueryActiveShellView|Description of QueryActiveShellView. PyObject *PyIShellBrowser::QueryActiveShellView(PyObject *self, PyObject *args) { --- 324,328 ---- } ! // @pymethod <o PyIShellView>|PyIShellBrowser|QueryActiveShellView|Returns the currently displayed view PyObject *PyIShellBrowser::QueryActiveShellView(PyObject *self, PyObject *args) { *************** *** 348,352 **** } ! // @pymethod |PyIShellBrowser|OnViewWindowActive|Description of OnViewWindowActive. PyObject *PyIShellBrowser::OnViewWindowActive(PyObject *self, PyObject *args) { --- 342,346 ---- } ! // @pymethod |PyIShellBrowser|OnViewWindowActive|Callback triggered when a view window is activated PyObject *PyIShellBrowser::OnViewWindowActive(PyObject *self, PyObject *args) { *************** *** 354,366 **** if ( pISB == NULL ) return NULL; ! // @pyparm <o PyIShellView>|pshv||Description for pshv PyObject *obpshv; IShellView *pshv; if ( !PyArg_ParseTuple(args, "O:OnViewWindowActive", &obpshv) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpshv, IID_IShellView, (void **)&pshv, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; --- 348,358 ---- if ( pISB == NULL ) return NULL; ! // @pyparm <o PyIShellView>|pshv||The activated view object PyObject *obpshv; IShellView *pshv; if ( !PyArg_ParseTuple(args, "O:OnViewWindowActive", &obpshv) ) return NULL; ! if (!PyCom_InterfaceFromPyInstanceOrObject(obpshv, IID_IShellView, (void **)&pshv, TRUE /* bNoneOK */)) ! return NULL; HRESULT hr; PY_INTERFACE_PRECALL; *************** *** 375,379 **** } ! // @pymethod |PyIShellBrowser|SetToolbarItems|Description of SetToolbarItems. PyObject *PyIShellBrowser::SetToolbarItems(PyObject *self, PyObject *args) { --- 367,371 ---- } ! // @pymethod |PyIShellBrowser|SetToolbarItems|Adds toolbar buttons to the browser's toolbar PyObject *PyIShellBrowser::SetToolbarItems(PyObject *self, PyObject *args) { *************** *** 383,395 **** 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; --- 375,388 ---- LPTBBUTTONSB lpButtons; PyObject *oblpButtons; ! ! UINT nButtons; UINT uFlags; ! if (!PyArg_ParseTuple(args, "OI:SetToolbarItems", ! &oblpButtons, // @pyparm <o PyLPTBBUTTONSB>|lpButtons||Sequence of tuples describing the buttons to be added ! &uFlags)) // @pyparm int|uFlags||Indicates button positions, combination of shellcon.FCT_* ! return NULL; ! if (!PyObject_AsTBBUTTONs( oblpButtons, &lpButtons, &nButtons )) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; *************** *** 408,424 **** static struct PyMethodDef PyIShellBrowser_methods[] = { ! { "InsertMenusSB", PyIShellBrowser::InsertMenusSB, 1 }, // @pymeth InsertMenusSB|Description of InsertMenusSB ! { "SetMenuSB", PyIShellBrowser::SetMenuSB, 1 }, // @pymeth SetMenuSB|Description of SetMenuSB ! { "RemoveMenusSB", PyIShellBrowser::RemoveMenusSB, 1 }, // @pymeth RemoveMenusSB|Description of RemoveMenusSB ! { "SetStatusTextSB", PyIShellBrowser::SetStatusTextSB, 1 }, // @pymeth SetStatusTextSB|Description of SetStatusTextSB ! { "EnableModelessSB", PyIShellBrowser::EnableModelessSB, 1 }, // @pymeth EnableModelessSB|Description of EnableModelessSB ! { "TranslateAcceleratorSB", PyIShellBrowser::TranslateAcceleratorSB, 1 }, // @pymeth TranslateAcceleratorSB|Description of TranslateAcceleratorSB ! { "BrowseObject", PyIShellBrowser::BrowseObject, 1 }, // @pymeth BrowseObject|Description of BrowseObject ! { "GetViewStateStream", PyIShellBrowser::GetViewStateStream, 1 }, // @pymeth GetViewStateStream|Description of GetViewStateStream ! { "GetControlWindow", PyIShellBrowser::GetControlWindow, 1 }, // @pymeth GetControlWindow|Description of GetControlWindow ! { "SendControlMsg", PyIShellBrowser::SendControlMsg, 1 }, // @pymeth SendControlMsg|Description of SendControlMsg ! { "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 } }; --- 401,417 ---- static struct PyMethodDef PyIShellBrowser_methods[] = { ! { "InsertMenusSB", PyIShellBrowser::InsertMenusSB, 1 }, // @pymeth InsertMenusSB|Updates a composite menu with container's options ! { "SetMenuSB", PyIShellBrowser::SetMenuSB, 1 }, // @pymeth SetMenuSB|Attaches a shared menu to a shell view window ! { "RemoveMenusSB", PyIShellBrowser::RemoveMenusSB, 1 }, // @pymeth RemoveMenusSB|Asks container to remove any items it added to a composite menu ! { "SetStatusTextSB", PyIShellBrowser::SetStatusTextSB, 1 }, // @pymeth SetStatusTextSB|Sets the status text in view's status bar ! { "EnableModelessSB", PyIShellBrowser::EnableModelessSB, 1 }, // @pymeth EnableModelessSB|Enables or disables modeless dialogs ! { "TranslateAcceleratorSB", PyIShellBrowser::TranslateAcceleratorSB, 1 }, // @pymeth TranslateAcceleratorSB|Translates keystrokes used as menu item activators ! { "BrowseObject", PyIShellBrowser::BrowseObject, 1 }, // @pymeth BrowseObject|Navigates to a different location ! { "GetViewStateStream", PyIShellBrowser::GetViewStateStream, 1 }, // @pymeth GetViewStateStream|Returns a stream that can be used to access view state information ! { "GetControlWindow", PyIShellBrowser::GetControlWindow, 1 }, // @pymeth GetControlWindow|Returns a handle to one of the browser's control elements ! { "SendControlMsg", PyIShellBrowser::SendControlMsg, 1 }, // @pymeth SendControlMsg|Sends a control msg to browser's toolbar or status bar ! { "QueryActiveShellView", PyIShellBrowser::QueryActiveShellView, 1 }, // @pymeth QueryActiveShellView|Returns the currently displayed view ! { "OnViewWindowActive", PyIShellBrowser::OnViewWindowActive, 1 }, // @pymeth OnViewWindowActive|Callback triggered when a view window is activated ! { "SetToolbarItems", PyIShellBrowser::SetToolbarItems, 1}, // @pymeth SetToolbarItems|Adds toolbar buttons to the browser's toolbar { NULL } }; *************** *** 442,446 **** if (oblpMenuWidths==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *result; ! HRESULT hr=InvokeViaPolicy("InsertMenusSB", &result, "iO", hmenuShared, oblpMenuWidths); Py_DECREF(oblpMenuWidths); if (FAILED(hr)) return hr; --- 435,439 ---- if (oblpMenuWidths==NULL) return PyCom_HandlePythonFailureToCOM(); PyObject *result; ! HRESULT hr=InvokeViaPolicy("InsertMenusSB", &result, "NO", PyWinLong_FromHANDLE(hmenuShared), oblpMenuWidths); Py_DECREF(oblpMenuWidths); if (FAILED(hr)) return hr; *************** *** 456,460 **** { PY_GATEWAY_METHOD; ! HRESULT hr=InvokeViaPolicy("SetMenuSB", NULL, "iil", hmenuShared, holemenuRes, hwndActiveObject); return hr; } --- 449,454 ---- { PY_GATEWAY_METHOD; ! HRESULT hr=InvokeViaPolicy("SetMenuSB", NULL, "NNN", PyWinLong_FromHANDLE(hmenuShared), ! PyWinLong_FromHANDLE(holemenuRes), PyWinLong_FromHANDLE(hwndActiveObject)); return hr; } *************** *** 464,468 **** { PY_GATEWAY_METHOD; ! HRESULT hr=InvokeViaPolicy("RemoveMenusSB", NULL, "i", hmenuShared); return hr; } --- 458,462 ---- { PY_GATEWAY_METHOD; ! HRESULT hr=InvokeViaPolicy("RemoveMenusSB", NULL, "N", PyWinLong_FromHANDLE(hmenuShared)); return hr; } *************** *** 494,498 **** PyObject *obpmsg = PyObject_FromMSG(pmsg); if (obpmsg==NULL) return PyCom_HandlePythonFailureToCOM(); ! HRESULT hr=InvokeViaPolicy("TranslateAcceleratorSB", NULL, "Oi", obpmsg, wID); Py_DECREF(obpmsg); return hr; --- 488,492 ---- PyObject *obpmsg = PyObject_FromMSG(pmsg); if (obpmsg==NULL) return PyCom_HandlePythonFailureToCOM(); ! HRESULT hr=InvokeViaPolicy("TranslateAcceleratorSB", NULL, "OH", obpmsg, wID); Py_DECREF(obpmsg); return hr; *************** *** 506,510 **** PyObject *obpidl; obpidl = PyObject_FromPIDL(pidl, FALSE); ! HRESULT hr=InvokeViaPolicy("BrowseObject", NULL, "Oi", obpidl, wFlags); Py_XDECREF(obpidl); return hr; --- 500,504 ---- PyObject *obpidl; obpidl = PyObject_FromPIDL(pidl, FALSE); ! HRESULT hr=InvokeViaPolicy("BrowseObject", NULL, "OI", obpidl, wFlags); Py_XDECREF(obpidl); return hr; *************** *** 536,544 **** PY_GATEWAY_METHOD; PyObject *result; ! HRESULT hr=InvokeViaPolicy("GetControlWindow", &result, "i", id); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! if (PyInt_Check(result) || PyLong_Check(result)) ! *phwnd = (HWND)PyInt_AsLong(result); Py_DECREF(result); return hr; --- 530,538 ---- PY_GATEWAY_METHOD; PyObject *result; ! HRESULT hr=InvokeViaPolicy("GetControlWindow", &result, "I", id); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! if (!PyWinObject_AsHANDLE(result, (HANDLE *)phwnd, TRUE)) ! hr = PyCom_HandlePythonFailureToCOM(); Py_DECREF(result); return hr; |