pywin32-checkins Mailing List for Python for Windows Extensions (Page 108)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Mark H. <mha...@us...> - 2005-10-21 02:25:57
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2524/win32/lib Modified Files: pywintypes.py Log Message: Give up on trying to safely import pywintypesXX.dll without help from an extension - so we have a new _win32sysloader.cpp which only claim to fame is that it does not link to pywintypes.dll. This prevents errors seen in Zope, when an (existing) pywintypesXX.dll lives in system32, and Zope installs its own next to its python.exe. In this case, importing (eg) win32api before pywintypes would cause bizarre type errors as the module was loaded twice. Index: pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywintypes.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pywintypes.py 2 Jul 2004 02:38:45 -0000 1.11 --- pywintypes.py 21 Oct 2005 02:25:49 -0000 1.12 *************** *** 2,14 **** def __import_pywin32_system_module__(modname, globs): ! # *sigh* - non-admin installs will not have pywintypesxx.dll in the ! # system directory, so 'import win32api' will fail looking ! # for pywintypes - the exact DLL we are trying to load! ! # So if it exists in sys.prefix, then we try and load it from ! # there, as that way we can avoid the win32api import import imp, sys, os if not sys.platform.startswith("win32"): # These extensions can be built on Linux via the 'mainwin' toolkit. # Look for a native 'lib{modname}.so' for ext, mode, ext_type in imp.get_suffixes(): if ext_type==imp.C_EXTENSION: --- 2,27 ---- def __import_pywin32_system_module__(modname, globs): ! # This has been through a number of iterations. The problem: how to ! # locate pywintypesXX.dll when it may be in a number of places, and how ! # to avoid ever loading it twice. This problem is compounded by the ! # fact that the "right" way to do this requires win32api, but this ! # itself requires pywintypesXX. ! # And the killer problem is that someone may have done 'import win32api' ! # before this code is called. In that case Windows will have already ! # loaded pywintypesXX as part of loading win32api - but by the time ! # we get here, we may locate a different one. This appears to work, but ! # then starts raising bizarre TypeErrors complaining that something ! # is not a pywintypes type when it clearly is! ! ! # So in what we hope is the last major iteration of this, we now ! # rely on a _win32sysloader module, implemented in C but not relying ! # on pywintypesXX.dll. It then can check if the DLL we are looking for ! # lib is already loaded. import imp, sys, os if not sys.platform.startswith("win32"): # These extensions can be built on Linux via the 'mainwin' toolkit. # Look for a native 'lib{modname}.so' + # NOTE: The _win32sysloader module will probably build in this + # environment, so it may be better to use that here too. for ext, mode, ext_type in imp.get_suffixes(): if ext_type==imp.C_EXTENSION: *************** *** 34,37 **** --- 47,52 ---- # If we are running from a frozen program (py2exe, McMillan, freeze) # then we try and load the DLL from our sys.path + # XXX - This path may also benefit from _win32sysloader? However, + # MarkH has never seen the DLL load problem with py2exe programs... for look in sys.path: # If the sys.path entry is a (presumably) .zip file, use the *************** *** 46,73 **** "Module '%s' isn't in frozen sys.path %s" % (modname, sys.path) else: ! # If there is a version in our Python directory, use that ! # (it may not be on the PATH, so may fail to be loaded by win32api) ! # Non-admin installs will have the system files there. ! found = None ! if os.path.isfile(os.path.join(sys.prefix, filename)): ! found = os.path.join(sys.prefix, filename) ! # Allow Windows to find it. We have tried various other tricks, ! # but in some cases, we ended up with *2* versions of the libraries ! # loaded - the one found by Windows when doing a later "import win32*", ! # and the one we found here. ! # A remaining trick would be to simulate LoadLibrary(), using the ! # registry to determine the system32 directory. However, Python ! # 2.2 doesn't have sys.getwindowsversion(), which is kinda needed ! # to determine the correct places to look. ! # The downside of this is that we need to use win32api, and this ! # depends on pywintypesxx.dll, which may be what we are trying to ! # find! If this fails, we get a dialog box, followed by the import ! # error. The dialog box is undesirable, but should only happen ! # when something is badly broken, and is a less harmful side-effect ! # than loading the DLL twice! if found is None: ! import win32api # failure here means Windows can't find it either! ! found = win32api.GetModuleFileName(win32api.LoadLibrary(filename)) # Python can load the module --- 61,96 ---- "Module '%s' isn't in frozen sys.path %s" % (modname, sys.path) else: ! # First see if it already in our process - if so, we must use that. ! import _win32sysloader ! found = _win32sysloader.GetModuleFilename(filename) ! if found is None: ! # We ask Windows to load it next. This is in an attempt to ! # get the exact same module loaded should pywintypes be imported ! # first (which is how we are here) or if, eg, win32api was imported ! # first thereby implicitly loading the DLL. ! # Sadly though, it doesn't quite work - if pywintypesxx.dll ! # is in system32 *and* the executable's directory, on XP SP2, an ! # import of win32api will cause Windows to load pywintypes ! # from system32, where LoadLibrary for that name will ! # load the one in the exe's dir. ! # That shouldn't really matter though, so long as we only ever ! # get one loaded. ! found = _win32sysloader.LoadModule(filename) if found is None: ! # Windows can't find it - which although isn't relevent here, ! # means that we *must* be the first win32 import, as an attempt ! # to import win32api etc would fail when Windows attempts to ! # locate the DLL. ! # This is most likely to happen for "non-admin" installs, where ! # we can't put the files anywhere else on the global path. ! ! # If there is a version in our Python directory, use that ! if os.path.isfile(os.path.join(sys.prefix, filename)): ! found = os.path.join(sys.prefix, filename) ! if found is None: ! # give up in disgust. ! raise ImportError, \ ! "No system module '%s' (%s)" % (modname, filename) # Python can load the module |
From: Mark H. <mha...@us...> - 2005-10-21 02:25:57
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2524/win32/src Added Files: _win32sysloader.cpp Log Message: Give up on trying to safely import pywintypesXX.dll without help from an extension - so we have a new _win32sysloader.cpp which only claim to fame is that it does not link to pywintypes.dll. This prevents errors seen in Zope, when an (existing) pywintypesXX.dll lives in system32, and Zope installs its own next to its python.exe. In this case, importing (eg) win32api before pywintypes would cause bizarre type errors as the module was loaded twice. --- NEW FILE: _win32sysloader.cpp --- /*********************************************************************** _win32sysloader.cpp -- a helper module for loading the PyWin32 "system" modules pywintypes and pythoncom. Note that this module does (and must) *NOT* link to pywintypesXX.dll See pywintypes.py for more information. ********************************************************************/ #include "windows.h" #include "Python.h" // GetModuleHandle and GetModuleFilename rolled into 1 static PyObject *PyGetModuleFilename(PyObject *self, PyObject *args) { char *modName; if (!PyArg_ParseTuple(args, "s", &modName)) return NULL; HINSTANCE hinst = GetModuleHandle(modName); if (hinst == NULL) { Py_INCREF(Py_None); return Py_None; } char buf[_MAX_PATH]; if (GetModuleFileName(hinst, buf, sizeof(buf))==0) { Py_INCREF(Py_None); return Py_None; } return PyString_FromString(buf); } static PyObject *PyLoadModule(PyObject *self, PyObject *args) { char *modName; if (!PyArg_ParseTuple(args, "s", &modName)) return NULL; HINSTANCE hinst = LoadLibrary(modName); if (hinst == NULL) { Py_INCREF(Py_None); return Py_None; } char buf[_MAX_PATH]; if (GetModuleFileName(hinst, buf, sizeof(buf))==0) { Py_INCREF(Py_None); return Py_None; } return PyString_FromString(buf); } static struct PyMethodDef functions[] = { {"GetModuleFilename", PyGetModuleFilename,1}, {"LoadModule", PyLoadModule,1}, { NULL } }; extern "C" __declspec(dllexport) void init_win32sysloader(void) { Py_InitModule("_win32sysloader", functions); } |
From: Mark H. <mha...@us...> - 2005-10-21 02:25:57
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2524 Modified Files: setup.py Log Message: Give up on trying to safely import pywintypesXX.dll without help from an extension - so we have a new _win32sysloader.cpp which only claim to fame is that it does not link to pywintypes.dll. This prevents errors seen in Zope, when an (existing) pywintypesXX.dll lives in system32, and Zope installs its own next to its python.exe. In this case, importing (eg) win32api before pywintypes would cause bizarre type errors as the module was loaded twice. Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** setup.py 20 Oct 2005 22:24:00 -0000 1.20 --- setup.py 21 Oct 2005 02:25:49 -0000 1.21 *************** *** 949,952 **** --- 949,953 ---- ("win32inet", "wininet", False), ("win32console", "kernel32", True, 0x0501, "win32/src/win32consolemodule.cpp"), + ("_win32sysloader", "", False, 0x0501, "win32/src/_win32sysloader.cpp"), ): |
From: Mark H. <mha...@us...> - 2005-10-20 22:36:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11717/include Modified Files: PyIRunningObjectTable.h Log Message: Add IRunningObjectTable::Register and Revoke. Index: PyIRunningObjectTable.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PyIRunningObjectTable.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyIRunningObjectTable.h 2 Nov 2003 09:57:45 -0000 1.2 --- PyIRunningObjectTable.h 20 Oct 2005 22:36:35 -0000 1.3 *************** *** 10,13 **** --- 10,15 ---- static PyObject *GetObject(PyObject *self, PyObject *args); static PyObject *EnumRunning(PyObject *self, PyObject *args); + static PyObject *Register(PyObject *self, PyObject *args); + static PyObject *Revoke(PyObject *self, PyObject *args); protected: |
From: Mark H. <mha...@us...> - 2005-10-20 22:36:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11717/extensions Modified Files: PyIRunningObjectTable.cpp Log Message: Add IRunningObjectTable::Register and Revoke. Index: PyIRunningObjectTable.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIRunningObjectTable.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIRunningObjectTable.cpp 2 Nov 2003 09:57:44 -0000 1.4 --- PyIRunningObjectTable.cpp 20 Oct 2005 22:36:35 -0000 1.5 *************** *** 92,98 **** --- 92,151 ---- } + // @pymethod int|PyIRunningObjectTable|Register|Registers an object and its identifying moniker in the Running Object Table (ROT). + PyObject *PyIRunningObjectTable::Register(PyObject *self, PyObject *args) + { + PyObject *obUnk, *obMk; + int flags; + if (!PyArg_ParseTuple(args, "iOO:Register", &flags, &obUnk, &obMk)) + return NULL; + + IRunningObjectTable *pMy = GetI(self); + if (pMy==NULL) return NULL; + + IUnknown *pUnknown; + if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&pUnknown, FALSE)) + return NULL; + + IMoniker *pMoniker; + if (!PyCom_InterfaceFromPyInstanceOrObject(obMk, IID_IMoniker, (void **)&pMoniker, FALSE)) { + pUnknown->Release(); + return NULL; + } + DWORD tok; + PY_INTERFACE_PRECALL; + HRESULT hr = pMy->Register(flags, pUnknown, pMoniker, &tok); + pMoniker->Release(); + pUnknown->Release(); + PY_INTERFACE_POSTCALL; + if (S_OK!=hr) // S_OK only acceptable + return PyCom_BuildPyException(hr, pMy, IID_IRunningObjectTable); + return PyInt_FromLong(tok); + } + + // @pymethod int|PyIRunningObjectTable|Revoke|Removes from the Running Object Table + // (ROT) an entry that was previously registered by a call to <om PyIRunningObjectTable.Register>. + PyObject *PyIRunningObjectTable::Revoke(PyObject *self, PyObject *args) + { + int tok; + if (!PyArg_ParseTuple(args, "i:Revoke", &tok)) + return NULL; + + IRunningObjectTable *pMy = GetI(self); + if (pMy==NULL) return NULL; + + PY_INTERFACE_PRECALL; + HRESULT hr = pMy->Revoke(tok); + PY_INTERFACE_POSTCALL; + if (S_OK!=hr) // S_OK only acceptable + return PyCom_BuildPyException(hr, pMy, IID_IRunningObjectTable); + Py_INCREF(Py_None); + return Py_None; + } + // @object PyIRunningObjectTable|A Python interface to IRunningObjectTable static struct PyMethodDef PyIRunningObjectTable_methods[] = { + {"Register", PyIRunningObjectTable::Register, 1}, // @pymeth Register|Registers an object in the ROT + {"Revoke", PyIRunningObjectTable::Revoke, 1}, // @pymeth Revoke|Revokes a previously registered object {"IsRunning", PyIRunningObjectTable::IsRunning, 1}, // @pymeth IsRunning|Checks whether an object is running. {"GetObject", PyIRunningObjectTable::GetObject, 1}, // @pymeth GetObject|Checks whether an object is running. |
From: Mark H. <mha...@us...> - 2005-10-20 22:36:15
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11660 Modified Files: PythonCOM.cpp Log Message: Add CoGetObject and CreateItemMoniker Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** PythonCOM.cpp 31 May 2005 12:36:02 -0000 1.36 --- PythonCOM.cpp 20 Oct 2005 22:36:07 -0000 1.37 *************** *** 883,886 **** --- 883,918 ---- } + // @pymethod <o PyIMoniker>|pythoncom|CreateItemMoniker|Creates an item moniker + // that identifies an object within a containing object (typically a compound document). + static PyObject *pythoncom_CreateItemMoniker(PyObject *self, PyObject *args) + { + PyObject *obDelim, *obItem; + // @pyparm string|delim||String containing the delimiter (typically "!") used to separate this item's display name from the display name of its containing object. + // @pyparm string|item||String indicating the containing object's name for the object being identified. + if ( !PyArg_ParseTuple(args, "OO:CreateItemMoniker", &obDelim, &obItem) ) + return NULL; + + BSTR bstrDelim, bstrItem; + if (!PyWinObject_AsBstr(obDelim, &bstrDelim, TRUE)) + return NULL; + + if (!PyWinObject_AsBstr(obItem, &bstrItem, FALSE)) { + PyWinObject_FreeBstr(bstrDelim); + return NULL; + } + + IMoniker *pmk; + PY_INTERFACE_PRECALL; + HRESULT hr = CreateItemMoniker(bstrDelim, bstrItem, &pmk); + PY_INTERFACE_POSTCALL; + PyWinObject_FreeBstr(bstrDelim); + PyWinObject_FreeBstr(bstrItem); + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr); + + return PyCom_PyObjectFromIUnknown(pmk, IID_IMoniker, FALSE); + } + // @pymethod <o PyIID>|pythoncom|GetClassFile|Supplies the CLSID associated with the given filename. static PyObject *pythoncom_GetClassFile(PyObject *self, PyObject *args) *************** *** 1121,1124 **** --- 1153,1192 ---- #endif // MS_WINCE + // @pymethod <o PyIUnknown>|pythoncom|CoGetObject|Converts a display name into a moniker that identifies the object named, and then binds to the object identified by the moniker. + static PyObject *pythoncom_CoGetObject(PyObject *self, PyObject*args) + { + PyObject *obName; + PyObject *obBindOpts = Py_None; + PyObject *obIID = Py_None; + if (!PyArg_ParseTuple(args, "O|OO:CoGetObject", + &obName, // @pyparm string|name|| + &obBindOpts, // @pyparm None|bindOpts||Must be None + &obIID )) // @pyparm <o PyIID>|iid||The IID if the interface to unmarshal. + return NULL; + + if (obBindOpts != Py_None) + return PyErr_Format(PyExc_ValueError, "BindOptions must be None"); + + IID iid; + if (obIID == Py_None) + iid = IID_IUnknown; + else { + if (!PyWinObject_AsIID(obIID, &iid)) + return NULL; + } + + PyWin_AutoFreeBstr name; + if (!PyWinObject_AsAutoFreeBstr(obName, &name)) + return NULL; + + IUnknown *pUnk; + PY_INTERFACE_PRECALL; + HRESULT hr = CoGetObject(name, NULL, iid, (void **)&pUnk); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + return PyCom_PyObjectFromIUnknown(pUnk, iid, /*BOOL bAddRef*/ FALSE); + } + // @pymethod |pythoncom|OleLoad|Loads into memory an object nested within a specified storage object. static PyObject *pythoncom_OleLoad(PyObject *self, PyObject* args) *************** *** 1580,1583 **** --- 1648,1652 ---- { "CoMarshalInterThreadInterfaceInStream", pythoncom_CoMarshalInterThreadInterfaceInStream, 1}, // @pymeth CoMarshalInterThreadInterfaceInStream|Marshals an interface pointer from one thread to another thread in the same process. #endif // MS_WINCE + { "CoGetObject", pythoncom_CoGetObject, 1}, // @pymeth CoGetObject|Converts a display name into a moniker that identifies the object named, and then binds to the object identified by the moniker. { "CoUninitialize", pythoncom_CoUninitialize, 1 }, // @pymeth CoUninitialize|Uninitialize the COM libraries. #ifndef MS_WINCE *************** *** 1592,1595 **** --- 1661,1665 ---- { "CreateBindCtx", pythoncom_CreateBindCtx, 1 }, // @pymeth CreateBindCtx|Obtains a <o PyIBindCtx> object. { "CreateFileMoniker", pythoncom_CreateFileMoniker, 1 }, // @pymeth CreateFileMoniker|Creates a file moniker given a file name. + { "CreateItemMoniker", pythoncom_CreateItemMoniker, 1 }, // @pymeth CreateItemMoniker|Creates an item moniker that identifies an object within a containing object (typically a compound document). { "CreatePointerMoniker", pythoncom_CreatePointerMoniker, 1 }, // @pymeth CreatePointerMoniker|Creates a pointer moniker based on a pointer to an object. { "CreateTypeLib", pythoncom_CreateTypeLib, 1}, // @pymeth CreateTypeLib|Provides access to a new object instance that supports the ICreateTypeLib interface. *************** *** 1909,1912 **** --- 1979,1985 ---- ADD_CONSTANT(REGCLS_SUSPENDED); + // ROT + ADD_CONSTANT(ROTFLAGS_REGISTRATIONKEEPSALIVE); + ADD_CONSTANT(ROTFLAGS_ALLOWANYCLIENT); // RPC ADD_CONSTANT(RPC_C_AUTHN_LEVEL_NONE); // RPC_C_AUTHN_LEVEL_NONE|Performs no authentication. |
From: Mark H. <mha...@us...> - 2005-10-20 22:32:36
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11001 Modified Files: oleargs.cpp Log Message: Allow a datetime object to be used directly as COM object arguments, rather than forcing you to call pythoncom.MakeTime() on the datetime object first. Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** oleargs.cpp 27 Jun 2005 11:02:41 -0000 1.30 --- oleargs.cpp 20 Oct 2005 22:32:28 -0000 1.31 *************** *** 148,152 **** V_ERROR(var) = DISP_E_PARAMNOTFOUND; } ! else if (PyTime_Check(obj)) { V_VT(var) = VT_DATE; --- 148,152 ---- V_ERROR(var) = DISP_E_PARAMNOTFOUND; } ! else if (PyTime_Check(obj) || PyObject_HasAttrString(obj, "timetuple")) { V_VT(var) = VT_DATE; |
From: Mark H. <mha...@us...> - 2005-10-20 22:31:08
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10701/com/win32comext/shell/src Modified Files: shell.cpp Log Message: Add .dll when doing a LoadLibrary of shlwapi and fix indentation of closing braces. Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** shell.cpp 18 Oct 2005 00:36:05 -0000 1.39 --- shell.cpp 20 Oct 2005 22:30:58 -0000 1.40 *************** *** 2224,2228 **** pfnSHILCreateFromPath=(PFNSHILCreateFromPath)GetProcAddress(shell32, "SHILCreateFromPath"); pfnSHShellFolderView_Message=(PFNSHShellFolderView_Message)GetProcAddress(shell32, "SHShellFolderView_Message"); ! } // SHGetFolderPath comes from shfolder.dll on older systems if (pfnSHGetFolderPath==NULL){ --- 2224,2228 ---- pfnSHILCreateFromPath=(PFNSHILCreateFromPath)GetProcAddress(shell32, "SHILCreateFromPath"); pfnSHShellFolderView_Message=(PFNSHShellFolderView_Message)GetProcAddress(shell32, "SHShellFolderView_Message"); ! } // SHGetFolderPath comes from shfolder.dll on older systems if (pfnSHGetFolderPath==NULL){ *************** *** 2232,2244 **** if (shfolder!=NULL) pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(shfolder, "SHGetFolderPathW"); ! } ! shlwapi=GetModuleHandle(TEXT("shlwapi")); if (shlwapi==NULL) ! shlwapi=LoadLibrary(TEXT("shlwapi")); if (shlwapi!=NULL){ pfnSHGetViewStatePropertyBag=(PFNSHGetViewStatePropertyBag)GetProcAddress(shlwapi, "SHGetViewStatePropertyBag"); pfnAssocCreate=(PFNAssocCreate)GetProcAddress(shlwapi, "AssocCreate"); ! } ADD_CONSTANT(SLR_NO_UI); --- 2232,2244 ---- if (shfolder!=NULL) pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(shfolder, "SHGetFolderPathW"); ! } ! shlwapi=GetModuleHandle(TEXT("shlwapi.dll")); if (shlwapi==NULL) ! shlwapi=LoadLibrary(TEXT("shlwapi.dll")); if (shlwapi!=NULL){ pfnSHGetViewStatePropertyBag=(PFNSHGetViewStatePropertyBag)GetProcAddress(shlwapi, "SHGetViewStatePropertyBag"); pfnAssocCreate=(PFNAssocCreate)GetProcAddress(shlwapi, "AssocCreate"); ! } ADD_CONSTANT(SLR_NO_UI); |
From: Mark H. <mha...@us...> - 2005-10-20 22:24:13
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9175 Modified Files: setup.py Log Message: axdebug seems to build again with a recent platform SDK. Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** setup.py 19 Sep 2005 12:25:27 -0000 1.19 --- setup.py 20 Oct 2005 22:24:00 -0000 1.20 *************** *** 1,3 **** ! build_id="204.2" # Putting buildno at the top prevents automatic __doc__ assignment, and # I *want* the build number at the top :) --- 1,3 ---- ! build_id="204.3" # Putting buildno at the top prevents automatic __doc__ assignment, and # I *want* the build number at the top :) *************** *** 24,32 **** Just install it - this setup script will automatically locate it. ! The 'axdebug' extension requires Active Debugging dev files available from: ! http://support.microsoft.com/default.aspx?kbid=223389 ! Download Scriptng.exe, unpack the files to a temporary directory and manually ! copy the .h and .lib files to your Platform SDK installation's include ! and lib directories, respectively -- overwriting some files of the same name. To install the pywin32 extensions, execute: --- 24,30 ---- Just install it - this setup script will automatically locate it. ! Note: 'axdebug' appears to work with recent Platform SDKs, with no ! additional software needed. It is probably necessary to select an appropriate ! "sub" SDK, but its not clear exactly which one yet (I just grabbed them all!) To install the pywin32 extensions, execute: *************** *** 61,65 **** pywin32_version='.'.join(sys.version.split('.')[:2])+'.'+build_id ! print pywin32_version # Python 2.2 has no True/False --- 59,63 ---- pywin32_version='.'.join(sys.version.split('.')[:2])+'.'+build_id ! print "Building pywin32", pywin32_version # Python 2.2 has no True/False *************** *** 372,376 **** v.ensure_value('dll',None) v.ensure_value('debug',None) ! v.ensure_value('verbose','1') for dirname, subdirs, fnames in os.walk(self.build_base): for fname in fnames: --- 370,374 ---- v.ensure_value('dll',None) v.ensure_value('debug',None) ! v.ensure_value('verbose','-v' in sys.argv) for dirname, subdirs, fnames in os.walk(self.build_base): for fname in fnames: *************** *** 1058,1062 **** WinExt_win32com('axdebug', dsp_file=r"com\Active Debugging.dsp", ! libraries="axscript ad1", pch_header = "stdafx.h", optional_headers = ["activdbg.h"], --- 1056,1060 ---- WinExt_win32com('axdebug', dsp_file=r"com\Active Debugging.dsp", ! libraries="axscript", pch_header = "stdafx.h", optional_headers = ["activdbg.h"], |
From: Roger U. <ru...@us...> - 2005-10-18 23:36:05
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11009/win32/Lib Added Files: winioctlcon.py Log Message: Constants, flags etc from winioctl.h for use with DeviceIoControl --- NEW FILE: winioctlcon.py --- ## flags, enums, guids used with DeviceIoControl from WinIoCtl.h import pywintypes from ntsecuritycon import FILE_READ_DATA,FILE_WRITE_DATA def CTL_CODE(DeviceType, Function, Method, Access): return (DeviceType << 16) | (Access << 14) | (Function << 2) | Method def DEVICE_TYPE_FROM_CTL_CODE(ctrlCode): return (ctrlCode & 0xffff0000) >> 16 FILE_DEVICE_BEEP = 0x00000001 FILE_DEVICE_CD_ROM = 0x00000002 FILE_DEVICE_CD_ROM_FILE_SYSTEM = 0x00000003 FILE_DEVICE_CONTROLLER = 0x00000004 FILE_DEVICE_DATALINK = 0x00000005 FILE_DEVICE_DFS = 0x00000006 FILE_DEVICE_DISK = 0x00000007 FILE_DEVICE_DISK_FILE_SYSTEM = 0x00000008 FILE_DEVICE_FILE_SYSTEM = 0x00000009 FILE_DEVICE_INPORT_PORT = 0x0000000a FILE_DEVICE_KEYBOARD = 0x0000000b FILE_DEVICE_MAILSLOT = 0x0000000c FILE_DEVICE_MIDI_IN = 0x0000000d FILE_DEVICE_MIDI_OUT = 0x0000000e FILE_DEVICE_MOUSE = 0x0000000f FILE_DEVICE_MULTI_UNC_PROVIDER = 0x00000010 FILE_DEVICE_NAMED_PIPE = 0x00000011 FILE_DEVICE_NETWORK = 0x00000012 FILE_DEVICE_NETWORK_BROWSER = 0x00000013 FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x00000014 FILE_DEVICE_NULL = 0x00000015 FILE_DEVICE_PARALLEL_PORT = 0x00000016 FILE_DEVICE_PHYSICAL_NETCARD = 0x00000017 FILE_DEVICE_PRINTER = 0x00000018 FILE_DEVICE_SCANNER = 0x00000019 FILE_DEVICE_SERIAL_MOUSE_PORT = 0x0000001a FILE_DEVICE_SERIAL_PORT = 0x0000001b FILE_DEVICE_SCREEN = 0x0000001c FILE_DEVICE_SOUND = 0x0000001d FILE_DEVICE_STREAMS = 0x0000001e FILE_DEVICE_TAPE = 0x0000001f FILE_DEVICE_TAPE_FILE_SYSTEM = 0x00000020 FILE_DEVICE_TRANSPORT = 0x00000021 FILE_DEVICE_UNKNOWN = 0x00000022 FILE_DEVICE_VIDEO = 0x00000023 FILE_DEVICE_VIRTUAL_DISK = 0x00000024 FILE_DEVICE_WAVE_IN = 0x00000025 FILE_DEVICE_WAVE_OUT = 0x00000026 FILE_DEVICE_8042_PORT = 0x00000027 FILE_DEVICE_NETWORK_REDIRECTOR = 0x00000028 FILE_DEVICE_BATTERY = 0x00000029 FILE_DEVICE_BUS_EXTENDER = 0x0000002a FILE_DEVICE_MODEM = 0x0000002b FILE_DEVICE_VDM = 0x0000002c FILE_DEVICE_MASS_STORAGE = 0x0000002d FILE_DEVICE_SMB = 0x0000002e FILE_DEVICE_KS = 0x0000002f FILE_DEVICE_CHANGER = 0x00000030 FILE_DEVICE_SMARTCARD = 0x00000031 FILE_DEVICE_ACPI = 0x00000032 FILE_DEVICE_DVD = 0x00000033 FILE_DEVICE_FULLSCREEN_VIDEO = 0x00000034 FILE_DEVICE_DFS_FILE_SYSTEM = 0x00000035 FILE_DEVICE_DFS_VOLUME = 0x00000036 FILE_DEVICE_SERENUM = 0x00000037 FILE_DEVICE_TERMSRV = 0x00000038 FILE_DEVICE_KSEC = 0x00000039 FILE_DEVICE_FIPS = 0x0000003A FILE_DEVICE_INFINIBAND = 0x0000003B METHOD_BUFFERED = 0 METHOD_IN_DIRECT = 1 METHOD_OUT_DIRECT = 2 METHOD_NEITHER = 3 METHOD_DIRECT_TO_HARDWARE = METHOD_IN_DIRECT METHOD_DIRECT_FROM_HARDWARE = METHOD_OUT_DIRECT FILE_ANY_ACCESS = 0 FILE_SPECIAL_ACCESS = FILE_ANY_ACCESS FILE_READ_ACCESS = 0x0001 FILE_WRITE_ACCESS = 0x0002 IOCTL_STORAGE_BASE = FILE_DEVICE_MASS_STORAGE RECOVERED_WRITES_VALID = 0x00000001 UNRECOVERED_WRITES_VALID = 0x00000002 RECOVERED_READS_VALID = 0x00000004 UNRECOVERED_READS_VALID = 0x00000008 WRITE_COMPRESSION_INFO_VALID = 0x00000010 READ_COMPRESSION_INFO_VALID = 0x00000020 TAPE_RETURN_STATISTICS = 0L TAPE_RETURN_ENV_INFO = 1L TAPE_RESET_STATISTICS = 2L MEDIA_ERASEABLE = 0x00000001 MEDIA_WRITE_ONCE = 0x00000002 MEDIA_READ_ONLY = 0x00000004 MEDIA_READ_WRITE = 0x00000008 MEDIA_WRITE_PROTECTED = 0x00000100 MEDIA_CURRENTLY_MOUNTED = 0x80000000 IOCTL_DISK_BASE = FILE_DEVICE_DISK PARTITION_ENTRY_UNUSED = 0x00 PARTITION_FAT_12 = 0x01 PARTITION_XENIX_1 = 0x02 PARTITION_XENIX_2 = 0x03 PARTITION_FAT_16 = 0x04 PARTITION_EXTENDED = 0x05 PARTITION_HUGE = 0x06 PARTITION_IFS = 0x07 PARTITION_OS2BOOTMGR = 0x0A PARTITION_FAT32 = 0x0B PARTITION_FAT32_XINT13 = 0x0C PARTITION_XINT13 = 0x0E PARTITION_XINT13_EXTENDED = 0x0F PARTITION_PREP = 0x41 PARTITION_LDM = 0x42 PARTITION_UNIX = 0x63 VALID_NTFT = 0xC0 PARTITION_NTFT = 0x80 GPT_ATTRIBUTE_PLATFORM_REQUIRED = 0x0000000000000001 GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER = 0x8000000000000000 GPT_BASIC_DATA_ATTRIBUTE_HIDDEN = 0x4000000000000000 GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY = 0x2000000000000000 GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY = 0x1000000000000000 HIST_NO_OF_BUCKETS = 24 DISK_LOGGING_START = 0 DISK_LOGGING_STOP = 1 DISK_LOGGING_DUMP = 2 DISK_BINNING = 3 CAP_ATA_ID_CMD = 1 CAP_ATAPI_ID_CMD = 2 CAP_SMART_CMD = 4 ATAPI_ID_CMD = 0xA1 ID_CMD = 0xEC SMART_CMD = 0xB0 SMART_CYL_LOW = 0x4F SMART_CYL_HI = 0xC2 SMART_NO_ERROR = 0 SMART_IDE_ERROR = 1 SMART_INVALID_FLAG = 2 SMART_INVALID_COMMAND = 3 SMART_INVALID_BUFFER = 4 SMART_INVALID_DRIVE = 5 SMART_INVALID_IOCTL = 6 SMART_ERROR_NO_MEM = 7 SMART_INVALID_REGISTER = 8 SMART_NOT_SUPPORTED = 9 SMART_NO_IDE_DEVICE = 10 SMART_OFFLINE_ROUTINE_OFFLINE = 0 SMART_SHORT_SELFTEST_OFFLINE = 1 SMART_EXTENDED_SELFTEST_OFFLINE = 2 SMART_ABORT_OFFLINE_SELFTEST = 127 SMART_SHORT_SELFTEST_CAPTIVE = 129 SMART_EXTENDED_SELFTEST_CAPTIVE = 130 READ_ATTRIBUTE_BUFFER_SIZE = 512 IDENTIFY_BUFFER_SIZE = 512 READ_THRESHOLD_BUFFER_SIZE = 512 SMART_LOG_SECTOR_SIZE = 512 READ_ATTRIBUTES = 0xD0 READ_THRESHOLDS = 0xD1 ENABLE_DISABLE_AUTOSAVE = 0xD2 SAVE_ATTRIBUTE_VALUES = 0xD3 EXECUTE_OFFLINE_DIAGS = 0xD4 SMART_READ_LOG = 0xD5 SMART_WRITE_LOG = 0xd6 ENABLE_SMART = 0xD8 DISABLE_SMART = 0xD9 RETURN_SMART_STATUS = 0xDA ENABLE_DISABLE_AUTO_OFFLINE = 0xDB IOCTL_CHANGER_BASE = FILE_DEVICE_CHANGER MAX_VOLUME_ID_SIZE = 36 MAX_VOLUME_TEMPLATE_SIZE = 40 VENDOR_ID_LENGTH = 8 PRODUCT_ID_LENGTH = 16 REVISION_LENGTH = 4 SERIAL_NUMBER_LENGTH = 32 CHANGER_BAR_CODE_SCANNER_INSTALLED = 0x00000001 CHANGER_INIT_ELEM_STAT_WITH_RANGE = 0x00000002 CHANGER_CLOSE_IEPORT = 0x00000004 CHANGER_OPEN_IEPORT = 0x00000008 CHANGER_STATUS_NON_VOLATILE = 0x00000010 CHANGER_EXCHANGE_MEDIA = 0x00000020 CHANGER_CLEANER_SLOT = 0x00000040 CHANGER_LOCK_UNLOCK = 0x00000080 CHANGER_CARTRIDGE_MAGAZINE = 0x00000100 CHANGER_MEDIUM_FLIP = 0x00000200 CHANGER_POSITION_TO_ELEMENT = 0x00000400 CHANGER_REPORT_IEPORT_STATE = 0x00000800 CHANGER_STORAGE_DRIVE = 0x00001000 CHANGER_STORAGE_IEPORT = 0x00002000 CHANGER_STORAGE_SLOT = 0x00004000 CHANGER_STORAGE_TRANSPORT = 0x00008000 CHANGER_DRIVE_CLEANING_REQUIRED = 0x00010000 CHANGER_PREDISMOUNT_EJECT_REQUIRED = 0x00020000 CHANGER_CLEANER_ACCESS_NOT_VALID = 0x00040000 CHANGER_PREMOUNT_EJECT_REQUIRED = 0x00080000 CHANGER_VOLUME_IDENTIFICATION = 0x00100000 CHANGER_VOLUME_SEARCH = 0x00200000 CHANGER_VOLUME_ASSERT = 0x00400000 CHANGER_VOLUME_REPLACE = 0x00800000 CHANGER_VOLUME_UNDEFINE = 0x01000000 CHANGER_SERIAL_NUMBER_VALID = 0x04000000 CHANGER_DEVICE_REINITIALIZE_CAPABLE = 0x08000000 CHANGER_KEYPAD_ENABLE_DISABLE = 0x10000000 CHANGER_DRIVE_EMPTY_ON_DOOR_ACCESS = 0x20000000 CHANGER_RESERVED_BIT = 0x80000000 CHANGER_PREDISMOUNT_ALIGN_TO_SLOT = 0x80000001 CHANGER_PREDISMOUNT_ALIGN_TO_DRIVE = 0x80000002 CHANGER_CLEANER_AUTODISMOUNT = 0x80000004 CHANGER_TRUE_EXCHANGE_CAPABLE = 0x80000008 CHANGER_SLOTS_USE_TRAYS = 0x80000010 CHANGER_RTN_MEDIA_TO_ORIGINAL_ADDR = 0x80000020 CHANGER_CLEANER_OPS_NOT_SUPPORTED = 0x80000040 CHANGER_IEPORT_USER_CONTROL_OPEN = 0x80000080 CHANGER_IEPORT_USER_CONTROL_CLOSE = 0x80000100 CHANGER_MOVE_EXTENDS_IEPORT = 0x80000200 CHANGER_MOVE_RETRACTS_IEPORT = 0x80000400 CHANGER_TO_TRANSPORT = 0x01 CHANGER_TO_SLOT = 0x02 CHANGER_TO_IEPORT = 0x04 CHANGER_TO_DRIVE = 0x08 LOCK_UNLOCK_IEPORT = 0x01 LOCK_UNLOCK_DOOR = 0x02 LOCK_UNLOCK_KEYPAD = 0x04 LOCK_ELEMENT = 0 UNLOCK_ELEMENT = 1 EXTEND_IEPORT = 2 RETRACT_IEPORT = 3 ELEMENT_STATUS_FULL = 0x00000001 ELEMENT_STATUS_IMPEXP = 0x00000002 ELEMENT_STATUS_EXCEPT = 0x00000004 ELEMENT_STATUS_ACCESS = 0x00000008 ELEMENT_STATUS_EXENAB = 0x00000010 ELEMENT_STATUS_INENAB = 0x00000020 ELEMENT_STATUS_PRODUCT_DATA = 0x00000040 ELEMENT_STATUS_LUN_VALID = 0x00001000 ELEMENT_STATUS_ID_VALID = 0x00002000 ELEMENT_STATUS_NOT_BUS = 0x00008000 ELEMENT_STATUS_INVERT = 0x00400000 ELEMENT_STATUS_SVALID = 0x00800000 ELEMENT_STATUS_PVOLTAG = 0x10000000 ELEMENT_STATUS_AVOLTAG = 0x20000000 ERROR_LABEL_UNREADABLE = 0x00000001 ERROR_LABEL_QUESTIONABLE = 0x00000002 ERROR_SLOT_NOT_PRESENT = 0x00000004 ERROR_DRIVE_NOT_INSTALLED = 0x00000008 ERROR_TRAY_MALFUNCTION = 0x00000010 ERROR_INIT_STATUS_NEEDED = 0x00000011 ERROR_UNHANDLED_ERROR = 0xFFFFFFFF SEARCH_ALL = 0x0 SEARCH_PRIMARY = 0x1 SEARCH_ALTERNATE = 0x2 SEARCH_ALL_NO_SEQ = 0x4 SEARCH_PRI_NO_SEQ = 0x5 SEARCH_ALT_NO_SEQ = 0x6 ASSERT_PRIMARY = 0x8 ASSERT_ALTERNATE = 0x9 REPLACE_PRIMARY = 0xA REPLACE_ALTERNATE = 0xB UNDEFINE_PRIMARY = 0xC UNDEFINE_ALTERNATE = 0xD USN_PAGE_SIZE = 0x1000 USN_REASON_DATA_OVERWRITE = 0x00000001 USN_REASON_DATA_EXTEND = 0x00000002 USN_REASON_DATA_TRUNCATION = 0x00000004 USN_REASON_NAMED_DATA_OVERWRITE = 0x00000010 USN_REASON_NAMED_DATA_EXTEND = 0x00000020 USN_REASON_NAMED_DATA_TRUNCATION = 0x00000040 USN_REASON_FILE_CREATE = 0x00000100 USN_REASON_FILE_DELETE = 0x00000200 USN_REASON_EA_CHANGE = 0x00000400 USN_REASON_SECURITY_CHANGE = 0x00000800 USN_REASON_RENAME_OLD_NAME = 0x00001000 USN_REASON_RENAME_NEW_NAME = 0x00002000 USN_REASON_INDEXABLE_CHANGE = 0x00004000 USN_REASON_BASIC_INFO_CHANGE = 0x00008000 USN_REASON_HARD_LINK_CHANGE = 0x00010000 USN_REASON_COMPRESSION_CHANGE = 0x00020000 USN_REASON_ENCRYPTION_CHANGE = 0x00040000 USN_REASON_OBJECT_ID_CHANGE = 0x00080000 USN_REASON_REPARSE_POINT_CHANGE = 0x00100000 USN_REASON_STREAM_CHANGE = 0x00200000 USN_REASON_CLOSE = 0x80000000 USN_DELETE_FLAG_DELETE = 0x00000001 USN_DELETE_FLAG_NOTIFY = 0x00000002 USN_DELETE_VALID_FLAGS = 0x00000003 USN_SOURCE_DATA_MANAGEMENT = 0x00000001 USN_SOURCE_AUXILIARY_DATA = 0x00000002 USN_SOURCE_REPLICATION_MANAGEMENT = 0x00000004 MARK_HANDLE_PROTECT_CLUSTERS = 1 MARK_HANDLE_TXF_SYSTEM_LOG = 4 MARK_HANDLE_NOT_TXF_SYSTEM_LOG = 8 VOLUME_IS_DIRTY = 0x00000001 VOLUME_UPGRADE_SCHEDULED = 0x00000002 FILE_PREFETCH_TYPE_FOR_CREATE = 0x1 FILESYSTEM_STATISTICS_TYPE_NTFS = 1 FILESYSTEM_STATISTICS_TYPE_FAT = 2 FILE_SET_ENCRYPTION = 0x00000001 FILE_CLEAR_ENCRYPTION = 0x00000002 STREAM_SET_ENCRYPTION = 0x00000003 STREAM_CLEAR_ENCRYPTION = 0x00000004 MAXIMUM_ENCRYPTION_VALUE = 0x00000004 ENCRYPTION_FORMAT_DEFAULT = 0x01 COMPRESSION_FORMAT_SPARSE = 0x4000 COPYFILE_SIS_LINK = 0x0001 COPYFILE_SIS_REPLACE = 0x0002 COPYFILE_SIS_FLAGS = 0x0003 WMI_DISK_GEOMETRY_GUID = pywintypes.IID("{25007F51-57C2-11D1-A528-00A0C9062910}") GUID_DEVINTERFACE_CDROM = pywintypes.IID("{53F56308-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_FLOPPY = pywintypes.IID("{53F56311-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR = pywintypes.IID("{4D36E978-E325-11CE-BFC1-08002BE10318}") GUID_DEVINTERFACE_COMPORT = pywintypes.IID("{86E0D1E0-8089-11D0-9CE4-08003E301F73}") GUID_DEVINTERFACE_DISK = pywintypes.IID("{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_STORAGEPORT = pywintypes.IID("{2ACCFE60-C130-11D2-B082-00A0C91EFB8B}") GUID_DEVINTERFACE_CDCHANGER = pywintypes.IID("{53F56312-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_PARTITION = pywintypes.IID("{53F5630A-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_VOLUME = pywintypes.IID("{53F5630D-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_WRITEONCEDISK = pywintypes.IID("{53F5630C-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_TAPE = pywintypes.IID("{53F5630B-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_DEVINTERFACE_MEDIUMCHANGER = pywintypes.IID("{53F56310-B6BF-11D0-94F2-00A0C91EFB8B}") GUID_SERENUM_BUS_ENUMERATOR = GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR GUID_CLASS_COMPORT = GUID_DEVINTERFACE_COMPORT DiskClassGuid = GUID_DEVINTERFACE_DISK CdRomClassGuid = GUID_DEVINTERFACE_CDROM PartitionClassGuid = GUID_DEVINTERFACE_PARTITION TapeClassGuid = GUID_DEVINTERFACE_TAPE WriteOnceDiskClassGuid = GUID_DEVINTERFACE_WRITEONCEDISK VolumeClassGuid = GUID_DEVINTERFACE_VOLUME MediumChangerClassGuid = GUID_DEVINTERFACE_MEDIUMCHANGER FloppyClassGuid = GUID_DEVINTERFACE_FLOPPY CdChangerClassGuid = GUID_DEVINTERFACE_CDCHANGER StoragePortClassGuid = GUID_DEVINTERFACE_STORAGEPORT IOCTL_STORAGE_CHECK_VERIFY = CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_CHECK_VERIFY2 = CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_MEDIA_REMOVAL = CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_EJECT_MEDIA = CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_LOAD_MEDIA = CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_LOAD_MEDIA2 = CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_RESERVE = CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_RELEASE = CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_FIND_NEW_DEVICES = CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_EJECTION_CONTROL = CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_MCN_CONTROL = CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_GET_MEDIA_TYPES = CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_GET_MEDIA_TYPES_EX = CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER = CTL_CODE(IOCTL_STORAGE_BASE, 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_GET_HOTPLUG_INFO = CTL_CODE(IOCTL_STORAGE_BASE, 0x0305, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_SET_HOTPLUG_INFO = CTL_CODE(IOCTL_STORAGE_BASE, 0x0306, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_STORAGE_RESET_BUS = CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_RESET_DEVICE = CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_BREAK_RESERVATION = CTL_CODE(IOCTL_STORAGE_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_STORAGE_GET_DEVICE_NUMBER = CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_STORAGE_PREDICT_FAILURE = CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_GET_DRIVE_GEOMETRY = CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_GET_PARTITION_INFO = CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_SET_PARTITION_INFO = CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_GET_DRIVE_LAYOUT = CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_SET_DRIVE_LAYOUT = CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_VERIFY = CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_FORMAT_TRACKS = CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_REASSIGN_BLOCKS = CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_PERFORMANCE = CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_IS_WRITABLE = CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_LOGGING = CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_FORMAT_TRACKS_EX = CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_HISTOGRAM_STRUCTURE = CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_HISTOGRAM_DATA = CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_HISTOGRAM_RESET = CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_REQUEST_STRUCTURE = CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_REQUEST_DATA = CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_PERFORMANCE_OFF = CTL_CODE(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_CONTROLLER_NUMBER = CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS) SMART_GET_VERSION = CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS) SMART_SEND_DRIVE_COMMAND = CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) SMART_RCV_DRIVE_DATA = CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_GET_PARTITION_INFO_EX = CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_SET_PARTITION_INFO_EX = CTL_CODE(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_GET_DRIVE_LAYOUT_EX = CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_SET_DRIVE_LAYOUT_EX = CTL_CODE(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_CREATE_DISK = CTL_CODE(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_GET_LENGTH_INFO = CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_GET_DRIVE_GEOMETRY_EX = CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_REASSIGN_BLOCKS_EX = CTL_CODE(IOCTL_DISK_BASE, 0x0029, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_UPDATE_DRIVE_SIZE = CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_GROW_PARTITION = CTL_CODE(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_GET_CACHE_INFORMATION = CTL_CODE(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_SET_CACHE_INFORMATION = CTL_CODE(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) OBSOLETE_IOCTL_STORAGE_RESET_BUS = CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) OBSOLETE_IOCTL_STORAGE_RESET_DEVICE = CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) ## the original define no longer exists in winioctl.h OBSOLETE_DISK_GET_WRITE_CACHE_STATE = CTL_CODE(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_GET_WRITE_CACHE_STATE=OBSOLETE_DISK_GET_WRITE_CACHE_STATE IOCTL_DISK_DELETE_DRIVE_LAYOUT = CTL_CODE(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_UPDATE_PROPERTIES = CTL_CODE(IOCTL_DISK_BASE, 0x0050, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_FORMAT_DRIVE = CTL_CODE(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_DISK_SENSE_DEVICE = CTL_CODE(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_DISK_CHECK_VERIFY = CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_MEDIA_REMOVAL = CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_EJECT_MEDIA = CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_LOAD_MEDIA = CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_RESERVE = CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_RELEASE = CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_FIND_NEW_DEVICES = CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_DISK_GET_MEDIA_TYPES = CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS) DISK_HISTOGRAM_SIZE = 72 HISTOGRAM_BUCKET_SIZE = 8 IOCTL_CHANGER_GET_PARAMETERS = CTL_CODE(IOCTL_CHANGER_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_CHANGER_GET_STATUS = CTL_CODE(IOCTL_CHANGER_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_CHANGER_GET_PRODUCT_DATA = CTL_CODE(IOCTL_CHANGER_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_CHANGER_SET_ACCESS = CTL_CODE(IOCTL_CHANGER_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_CHANGER_GET_ELEMENT_STATUS = CTL_CODE(IOCTL_CHANGER_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS = CTL_CODE(IOCTL_CHANGER_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_CHANGER_SET_POSITION = CTL_CODE(IOCTL_CHANGER_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_CHANGER_EXCHANGE_MEDIUM = CTL_CODE(IOCTL_CHANGER_BASE, 0x0008, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_CHANGER_MOVE_MEDIUM = CTL_CODE(IOCTL_CHANGER_BASE, 0x0009, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_CHANGER_REINITIALIZE_TRANSPORT = CTL_CODE(IOCTL_CHANGER_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS) IOCTL_CHANGER_QUERY_VOLUME_TAGS = CTL_CODE(IOCTL_CHANGER_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) IOCTL_SERIAL_LSRMST_INSERT = CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS) IOCTL_SERENUM_EXPOSE_HARDWARE = CTL_CODE(FILE_DEVICE_SERENUM,128,METHOD_BUFFERED,FILE_ANY_ACCESS) IOCTL_SERENUM_REMOVE_HARDWARE = CTL_CODE(FILE_DEVICE_SERENUM,129,METHOD_BUFFERED,FILE_ANY_ACCESS) IOCTL_SERENUM_PORT_DESC = CTL_CODE(FILE_DEVICE_SERENUM,130,METHOD_BUFFERED,FILE_ANY_ACCESS) IOCTL_SERENUM_GET_PORT_NAME = CTL_CODE(FILE_DEVICE_SERENUM,131,METHOD_BUFFERED,FILE_ANY_ACCESS) SERIAL_LSRMST_ESCAPE = 0x00 SERIAL_LSRMST_LSR_DATA = 0x01 SERIAL_LSRMST_LSR_NODATA = 0x02 SERIAL_LSRMST_MST = 0x03 SERIAL_IOC_FCR_FIFO_ENABLE = 0x00000001 SERIAL_IOC_FCR_RCVR_RESET = 0x00000002 SERIAL_IOC_FCR_XMIT_RESET = 0x00000004 SERIAL_IOC_FCR_DMA_MODE = 0x00000008 SERIAL_IOC_FCR_RES1 = 0x00000010 SERIAL_IOC_FCR_RES2 = 0x00000020 SERIAL_IOC_FCR_RCVR_TRIGGER_LSB = 0x00000040 SERIAL_IOC_FCR_RCVR_TRIGGER_MSB = 0x00000080 SERIAL_IOC_MCR_DTR = 0x00000001 SERIAL_IOC_MCR_RTS = 0x00000002 SERIAL_IOC_MCR_OUT1 = 0x00000004 SERIAL_IOC_MCR_OUT2 = 0x00000008 SERIAL_IOC_MCR_LOOP = 0x00000010 FSCTL_REQUEST_OPLOCK_LEVEL_1 = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_REQUEST_OPLOCK_LEVEL_2 = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_REQUEST_BATCH_OPLOCK = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_OPLOCK_BREAK_ACKNOWLEDGE = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_OPBATCH_ACK_CLOSE_PENDING = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_OPLOCK_BREAK_NOTIFY = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_LOCK_VOLUME = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_UNLOCK_VOLUME = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_DISMOUNT_VOLUME = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_IS_VOLUME_MOUNTED = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_IS_PATHNAME_VALID = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_MARK_VOLUME_DIRTY = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_QUERY_RETRIEVAL_POINTERS = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_GET_COMPRESSION = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_SET_COMPRESSION = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) FSCTL_MARK_AS_SYSTEM_HIVE = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_OPLOCK_BREAK_ACK_NO_2 = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_INVALIDATE_VOLUMES = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_QUERY_FAT_BPB = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_REQUEST_FILTER_OPLOCK = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_FILESYSTEM_GET_STATISTICS = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_GET_NTFS_VOLUME_DATA = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_GET_NTFS_FILE_RECORD = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_GET_VOLUME_BITMAP = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_GET_RETRIEVAL_POINTERS = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_MOVE_FILE = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) FSCTL_IS_VOLUME_DIRTY = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_ALLOW_EXTENDED_DASD_IO = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_FIND_FILES_BY_SID = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_SET_OBJECT_ID = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) FSCTL_GET_OBJECT_ID = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_DELETE_OBJECT_ID = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) FSCTL_SET_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) FSCTL_GET_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_DELETE_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) FSCTL_ENUM_USN_DATA = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_SECURITY_ID_CHECK = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, FILE_READ_DATA) FSCTL_READ_USN_JOURNAL = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_SET_OBJECT_ID_EXTENDED = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) FSCTL_CREATE_OR_GET_OBJECT_ID = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_SET_SPARSE = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) FSCTL_SET_ZERO_DATA = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA) FSCTL_QUERY_ALLOCATED_RANGES = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER, FILE_READ_DATA) FSCTL_SET_ENCRYPTION = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_ENCRYPTION_FSCTL_IO = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_WRITE_RAW_ENCRYPTED = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER, FILE_SPECIAL_ACCESS) FSCTL_READ_RAW_ENCRYPTED = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER, FILE_SPECIAL_ACCESS) FSCTL_CREATE_USN_JOURNAL = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_READ_FILE_USN_DATA = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_WRITE_USN_CLOSE_RECORD = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_EXTEND_VOLUME = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_QUERY_USN_JOURNAL = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_DELETE_USN_JOURNAL = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_MARK_HANDLE = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_SIS_COPYFILE = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS) FSCTL_SIS_LINK_FILES = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) FSCTL_HSM_MSG = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 66, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) FSCTL_HSM_DATA = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 68, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA) FSCTL_RECALL_FILE = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS) FSCTL_READ_FROM_PLEX = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA) FSCTL_FILE_PREFETCH = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) IOCTL_VOLUME_BASE = ord('V') IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS = CTL_CODE(IOCTL_VOLUME_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS) IOCTL_VOLUME_IS_CLUSTERED = CTL_CODE(IOCTL_VOLUME_BASE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS) ## enums ## STORAGE_MEDIA_TYPE DDS_4mm = 32 MiniQic = 33 Travan = 34 QIC = 35 MP_8mm = 36 AME_8mm = 37 AIT1_8mm = 38 DLT = 39 NCTP = 40 IBM_3480 = 41 IBM_3490E = 42 IBM_Magstar_3590 = 43 IBM_Magstar_MP = 44 STK_DATA_D3 = 45 SONY_DTF = 46 DV_6mm = 47 DMI = 48 SONY_D2 = 49 CLEANER_CARTRIDGE = 50 CD_ROM = 51 CD_R = 52 CD_RW = 53 DVD_ROM = 54 DVD_R = 55 DVD_RW = 56 MO_3_RW = 57 MO_5_WO = 58 MO_5_RW = 59 MO_5_LIMDOW = 60 PC_5_WO = 61 PC_5_RW = 62 PD_5_RW = 63 ABL_5_WO = 64 PINNACLE_APEX_5_RW = 65 SONY_12_WO = 66 PHILIPS_12_WO = 67 HITACHI_12_WO = 68 CYGNET_12_WO = 69 KODAK_14_WO = 70 MO_NFR_525 = 71 NIKON_12_RW = 72 IOMEGA_ZIP = 73 IOMEGA_JAZ = 74 SYQUEST_EZ135 = 75 SYQUEST_EZFLYER = 76 SYQUEST_SYJET = 77 AVATAR_F2 = 78 MP2_8mm = 79 DST_S = 80 DST_M = 81 DST_L = 82 VXATape_1 = 83 VXATape_2 = 84 STK_9840 = 85 LTO_Ultrium = 86 LTO_Accelis = 87 DVD_RAM = 88 AIT_8mm = 89 ADR_1 = 90 ADR_2 = 91 STK_9940 = 92 ## STORAGE_BUS_TYPE BusTypeUnknown = 0 BusTypeScsi = 1 BusTypeAtapi = 2 BusTypeAta = 3 BusType1394 = 4 BusTypeSsa = 5 BusTypeFibre = 6 BusTypeUsb = 7 BusTypeRAID = 8 BusTypeiScsi = 9 BusTypeSas = 10 BusTypeSata = 11 BusTypeMaxReserved = 127 ## MEDIA_TYPE Unknown = 0 F5_1Pt2_512 = 1 F3_1Pt44_512 = 2 F3_2Pt88_512 = 3 F3_20Pt8_512 = 4 F3_720_512 = 5 F5_360_512 = 6 F5_320_512 = 7 F5_320_1024 = 8 F5_180_512 = 9 F5_160_512 = 10 RemovableMedia = 11 FixedMedia = 12 F3_120M_512 = 13 F3_640_512 = 14 F5_640_512 = 15 F5_720_512 = 16 F3_1Pt2_512 = 17 F3_1Pt23_1024 = 18 F5_1Pt23_1024 = 19 F3_128Mb_512 = 20 F3_230Mb_512 = 21 F8_256_128 = 22 F3_200Mb_512 = 23 F3_240M_512 = 24 F3_32M_512 = 25 ## PARTITION_STYLE PARTITION_STYLE_MBR = 0 PARTITION_STYLE_GPT = 1 PARTITION_STYLE_RAW = 2 ## DETECTION_TYPE DetectNone = 0 DetectInt13 = 1 DetectExInt13 = 2 ## DISK_CACHE_RETENTION_PRIORITY EqualPriority = 0 KeepPrefetchedData = 1 KeepReadData = 2 ## DISK_WRITE_CACHE_STATE - ?????? this enum has disappeared from winioctl.h in windows 2003 SP1 sdk ?????? DiskWriteCacheNormal = 0 DiskWriteCacheForceDisable = 1 DiskWriteCacheDisableNotSupported = 2 ## BIN_TYPES RequestSize = 0 RequestLocation = 1 ## CHANGER_DEVICE_PROBLEM_TYPE DeviceProblemNone = 0 DeviceProblemHardware = 1 DeviceProblemCHMError = 2 DeviceProblemDoorOpen = 3 DeviceProblemCalibrationError = 4 DeviceProblemTargetFailure = 5 DeviceProblemCHMMoveError = 6 DeviceProblemCHMZeroError = 7 DeviceProblemCartridgeInsertError = 8 DeviceProblemPositionError = 9 DeviceProblemSensorError = 10 DeviceProblemCartridgeEjectError = 11 DeviceProblemGripperError = 12 DeviceProblemDriveError = 13 |
From: Roger U. <ru...@us...> - 2005-10-18 00:36:15
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10004/com/win32comext/shell/src Modified Files: PyIShellFolder.cpp shell.cpp Log Message: Replace deprecated SHGetMalloc operations with CoTaskMemAlloc/CoTaskMemFree Fix memory leak in PyIShellFolder::CompareIDs Autoduck fixes Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** shell.cpp 17 Oct 2005 00:15:51 -0000 1.38 --- shell.cpp 18 Oct 2005 00:36:05 -0000 1.39 *************** *** 80,99 **** void PyShell_FreeMem(void *p) { ! IMalloc *pMalloc; ! if (p && SHGetMalloc(&pMalloc)==S_OK) { ! pMalloc->Free(p); ! pMalloc->Release(); ! } } void *PyShell_AllocMem(ULONG cb) { ! IMalloc *pMalloc; ! if (SHGetMalloc(&pMalloc)==S_OK) { ! void *rc = pMalloc->Alloc(cb); ! pMalloc->Release(); ! return rc; ! } ! return NULL; } --- 80,90 ---- void PyShell_FreeMem(void *p) { ! if (p!=NULL) ! CoTaskMemFree(p); } void *PyShell_AllocMem(ULONG cb) { ! return CoTaskMemAlloc(cb); } *************** *** 119,124 **** { if (pidl==NULL) { - if (bFreeSystemPIDL) - PyShell_FreeMem( (void *)pidl); Py_INCREF(Py_None); return Py_None; --- 110,113 ---- Index: PyIShellFolder.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellFolder.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyIShellFolder.cpp 15 Dec 2004 01:07:51 -0000 1.10 --- PyIShellFolder.cpp 18 Oct 2005 00:36:05 -0000 1.11 *************** *** 27,34 **** } ! // @pymethod |PyIShellFolder|ParseDisplayName|Description of ParseDisplayName. ! // @rdesc The result is a tuple of cchEaten, pidl, attr. ! // cchEaten will have been initialized to -1, and may or may not be changed ! // for the return value. PyObject *PyIShellFolder::ParseDisplayName(PyObject *self, PyObject *args) { --- 27,35 ---- } ! // @pymethod tuple|PyIShellFolder|ParseDisplayName|Returns the PIDL of an item in a shell folder ! // @rdesc The result is a tuple of cchEaten, pidl, attr ! // @tupleitem 0|int|cchEaten|the number of characters of the input name that were parsed ! // @tupleitem 1|<o PyIDL>|pidl|specifies the relative path from the parsing folder to the object ! // @tupleitem 2|int|Attributes|returns any requested attributes PyObject *PyIShellFolder::ParseDisplayName(PyObject *self, PyObject *args) { *************** *** 36,42 **** if ( pISF == NULL ) return NULL; ! // @pyparm HWND|hwndOwner||Description for hwndOwner ! // @pyparm <o PyIBindCtx>|pbcReserved||Description for pbcReserved ! // @pyparm <o unicode>|lpszDisplayName||Description for lpszDisplayName PyObject *obpbcReserved; PyObject *oblpszDisplayName; --- 37,46 ---- if ( pISF == NULL ) return NULL; ! // @pyparm HWND|hwndOwner||Window in which to display any dialogs or message boxes, can be 0 ! // @pyparm <o PyIBindCtx>|pbc||Bind context that affects how parsing is performed, can be None ! // @pyparm <o PyUNICODE>|DisplayName||Display name to parse, format is dependent on the shell folder. ! // Desktop folder will accept a file path, as well as guids of the form ::{guid} ! // Example: '::%s\\::%s' %(shell.CLSID_MyComputer,shell.CLSID_ControlPanel) ! // @pyparm int|Attributes|0|Combination of shellcon.SFGAO_* constants specifying which attributes should be returned PyObject *obpbcReserved; PyObject *oblpszDisplayName; *************** *** 47,51 **** ITEMIDLIST *ppidl; ULONG pdwAttributes = 0; ! if ( !PyArg_ParseTuple(args, "lOO|l:ParseDisplayName", &hwndOwner, &obpbcReserved, &oblpszDisplayName, &pdwAttributes) ) return NULL; --- 51,55 ---- ITEMIDLIST *ppidl; ULONG pdwAttributes = 0; ! if ( !PyArg_ParseTuple(args, "lOO|k:ParseDisplayName", &hwndOwner, &obpbcReserved, &oblpszDisplayName, &pdwAttributes) ) return NULL; *************** *** 74,78 **** } ! // @pymethod |PyIShellFolder|EnumObjects|Description of EnumObjects. PyObject *PyIShellFolder::EnumObjects(PyObject *self, PyObject *args) { --- 78,82 ---- } ! // @pymethod <o PyIEnumIDList>|PyIShellFolder|EnumObjects|Creates an enumerator to list the contents of the shell folder PyObject *PyIShellFolder::EnumObjects(PyObject *self, PyObject *args) { *************** *** 80,85 **** if ( pISF == NULL ) return NULL; ! // @pyparm HWND|hwndOwner|0|Description for hwndOwner ! // @pyparm int|grfFlags|SHCONTF_FOLDERS\|SHCONTF_NONFOLDERS\|SHCONTF_INCLUDEHIDDEN|Description for grfFlags HWND hwndOwner = 0; DWORD grfFlags = SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN; --- 84,89 ---- if ( pISF == NULL ) return NULL; ! // @pyparm HWND|hwndOwner|0|Window to use if any user interaction is required ! // @pyparm int|grfFlags|SHCONTF_FOLDERS\|SHCONTF_NONFOLDERS\|SHCONTF_INCLUDEHIDDEN|Combination of shellcon.SHCONTF_* constants HWND hwndOwner = 0; DWORD grfFlags = SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN; *************** *** 99,103 **** } ! // @pymethod |PyIShellFolder|BindToObject|Description of BindToObject. PyObject *PyIShellFolder::BindToObject(PyObject *self, PyObject *args) { --- 103,107 ---- } ! // @pymethod <o PyIShellFolder>|PyIShellFolder|BindToObject|Returns an IShellFolder interface for a subfolder PyObject *PyIShellFolder::BindToObject(PyObject *self, PyObject *args) { *************** *** 105,111 **** if ( pISF == NULL ) return NULL; ! // @pyparm <o PyIDL>|pidl||Description for pidl ! // @pyparm <o PyIBindCtx>|pbcReserved||Description for pbcReserved ! // @pyparm <o PyIID>|riid||Description for riid PyObject *obpidl; PyObject *obpbcReserved; --- 109,115 ---- if ( pISF == NULL ) return NULL; ! // @pyparm <o PyIDL>|pidl||Relative item id list that identifies the subfolder, can be multi-level ! // @pyparm <o PyIBindCtx>|pbc||Bind context to be used, can be None ! // @pyparm <o PyIID>|riid||IID of the desired interface, usually IID_IShellFolder PyObject *obpidl; PyObject *obpbcReserved; *************** *** 122,126 **** bPythonIsHappy = FALSE; if (!PyWinObject_AsIID(obriid, &riid)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; --- 126,130 ---- bPythonIsHappy = FALSE; if (!PyWinObject_AsIID(obriid, &riid)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; // this could leak the pidl HRESULT hr; PY_INTERFACE_PRECALL; *************** *** 137,141 **** } ! // @pymethod |PyIShellFolder|BindToStorage|Description of BindToStorage. PyObject *PyIShellFolder::BindToStorage(PyObject *self, PyObject *args) { --- 141,146 ---- } ! // @pymethod interface|PyIShellFolder|BindToStorage|Returns an interface to a storage object in a shell folder ! // @rdesc Returns <o PyIStream>, <o PyIStorage> or <o PyIPropertySetStorage> depending on the riid passed in PyObject *PyIShellFolder::BindToStorage(PyObject *self, PyObject *args) { *************** *** 143,149 **** if ( pISF == NULL ) return NULL; ! // @pyparm <o PyIDL>|pidl||Description for pidl ! // @pyparm <o PyIBindCtx>|pbcReserved||Description for pbcReserved ! // @pyparm <o PyIID>|riid||Description for riid PyObject *obpidl; PyObject *obpbcReserved; --- 148,154 ---- if ( pISF == NULL ) return NULL; ! // @pyparm <o PyIDL>|pidl||Relative pidl for the folder item, must be a single item id ! // @pyparm <o PyIBindCtx>|pbc||Bind context that affects how binding is performed, can be None ! // @pyparm <o PyIID>|riid||IID of the desired interface, one of IID_IStream, IID_IStorage, IID_IPropertySetStorage PyObject *obpidl; PyObject *obpbcReserved; *************** *** 175,179 **** } ! // @pymethod int|PyIShellFolder|CompareIDs|Description of CompareIDs. PyObject *PyIShellFolder::CompareIDs(PyObject *self, PyObject *args) { --- 180,185 ---- } ! // @pymethod int|PyIShellFolder|CompareIDs|Determines the sorting order of 2 items in shell folder ! // @rdesc Returns 0 if items compare equal, -1 if the pidl1 comes first, or 1 if pidl2 comes first PyObject *PyIShellFolder::CompareIDs(PyObject *self, PyObject *args) { *************** *** 181,219 **** if ( pISF == NULL ) return NULL; ! // @pyparm int|lparam||Description for lparam ! // @pyparm <o PyIDL>|pidl1||Description for pidl1 ! // @pyparm <o PyIDL>|pidl2||Description for pidl2 PyObject *obpidl1; PyObject *obpidl2; long lparam; ! ITEMIDLIST *pidl1; ! ITEMIDLIST *pidl2; ! if ( !PyArg_ParseTuple(args, "lOO:CompareIDs", &lparam, &obpidl1, &obpidl2) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyObject_AsPIDL(obpidl1, &pidl1)) bPythonIsHappy = FALSE; ! if (bPythonIsHappy && !PyObject_AsPIDL(obpidl2, &pidl2)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; ! HRESULT hr; ! PY_INTERFACE_PRECALL; ! hr = pISF->CompareIDs( lparam, pidl1, pidl2 ); PyObject_FreePIDL(pidl1); PyObject_FreePIDL(pidl2); ! ! PY_INTERFACE_POSTCALL; ! ! if ( FAILED(hr) ) ! return PyCom_BuildPyException(hr, pISF, IID_IShellFolder ); ! ! // special handling of hresult ! if ((short)HRESULT_CODE(hr) < 0) ! /* pidl1 comes first */ ! return PyInt_FromLong(-1); ! else if ((short)HRESULT_CODE(hr) > 0) ! /* pidl2 comes first */ ! return PyInt_FromLong(1); ! else ! /* the two pidls are equal */ ! return PyInt_FromLong(0); } --- 187,226 ---- if ( pISF == NULL ) return NULL; ! // @pyparm int|lparam||Lower 16 bits specify folder-dependent sorting rules, 0 means to sort by display name. ! // System folder view uses these as a column number.<nl> ! // Upper sixteen bits is used for flags SHCIDS_ALLFIELDS or SHCIDS_CANONICALONLY ! // @pyparm <o PyIDL>|pidl1||Item id list that idenfies an object relative to the folder ! // @pyparm <o PyIDL>|pidl2||Item id list that idenfies an object relative to the folder PyObject *obpidl1; PyObject *obpidl2; + PyObject *ret=NULL; long lparam; ! ITEMIDLIST *pidl1=NULL; ! ITEMIDLIST *pidl2=NULL; ! if ( !PyArg_ParseTuple(args, "kOO:CompareIDs", &lparam, &obpidl1, &obpidl2) ) return NULL; ! ! if (PyObject_AsPIDL(obpidl1, &pidl1) && ! PyObject_AsPIDL(obpidl2, &pidl2)){ ! HRESULT hr; ! PY_INTERFACE_PRECALL; ! hr = pISF->CompareIDs( lparam, pidl1, pidl2 ); ! PY_INTERFACE_POSTCALL; ! if ( FAILED(hr) ) ! PyCom_BuildPyException(hr, pISF, IID_IShellFolder ); ! else // special handling of hresult ! if ((short)HRESULT_CODE(hr) < 0) ! /* pidl1 comes first */ ! ret=PyInt_FromLong(-1); ! else if ((short)HRESULT_CODE(hr) > 0) ! /* pidl2 comes first */ ! ret=PyInt_FromLong(1); ! else ! /* the two pidls are equal */ ! ret=PyInt_FromLong(0); ! } PyObject_FreePIDL(pidl1); PyObject_FreePIDL(pidl2); ! return ret; } |
From: Roger U. <ru...@us...> - 2005-10-17 00:16:00
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28472/com/win32comext/shell/src Modified Files: shell.cpp Log Message: Add SHSetFolderPath, some autoduck fixes Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** shell.cpp 16 May 2005 07:09:39 -0000 1.37 --- shell.cpp 17 Oct 2005 00:15:51 -0000 1.38 *************** *** 60,63 **** --- 60,66 ---- static PFNSHGetFolderPath pfnSHGetFolderPath = NULL; + typedef HRESULT (WINAPI *PFNSHSetFolderPath)(int, HANDLE, DWORD, LPCWSTR); + static PFNSHSetFolderPath pfnSHSetFolderPath = NULL; + typedef HRESULT (WINAPI *PFNSHQueryRecycleBin)(LPCWSTR, LPSHQUERYRBINFO); static PFNSHQueryRecycleBin pfnSHQueryRecycleBin = NULL; *************** *** 72,75 **** --- 75,81 ---- static PFNAssocCreate pfnAssocCreate = NULL; + typedef LRESULT (WINAPI *PFNSHShellFolderView_Message)(HWND, UINT, LPARAM); + static PFNSHShellFolderView_Message pfnSHShellFolderView_Message = NULL; + void PyShell_FreeMem(void *p) { *************** *** 1134,1137 **** --- 1140,1176 ---- } + // @pymethod |shell|SHSetFolderPath|Sets the location of one of the special folders + // @comm This function is only available on Windows 2000 or later + static PyObject *PySHSetFolderPath(PyObject *self, PyObject *args) + { + int csidl; + HANDLE hToken; + DWORD Flags=0; // Flags is reserved + PyObject *obToken=Py_None, *obPath; + WCHAR *Path; + + if (pfnSHSetFolderPath==NULL) + return OleSetOleError(E_NOTIMPL); + if(!PyArg_ParseTuple(args, "lO|O:SHSetFolderPath", + &csidl, // @pyparm int|csidl||One of the shellcon.CSIDL_* values + &obPath, // @pyparm str/unicode|Path||The full path to be set + &obToken)) // @pyparm <o PyHANDLE>|hToken|None|Handle to an access token, can be None + return NULL; + if (!PyWinObject_AsHANDLE(obToken, &hToken, TRUE)) + return NULL; + if (!PyWinObject_AsWCHAR(obPath, &Path, FALSE)) + return NULL; + + PY_INTERFACE_PRECALL; + HRESULT hr = (*pfnSHSetFolderPath)(csidl, hToken, Flags, Path); + PY_INTERFACE_POSTCALL; + + PyWinObject_FreeWCHAR(Path); + if (FAILED(hr)) + return OleSetOleError(hr); + Py_INCREF(Py_None); + return Py_None; + } + // @pymethod <o PyIDL>|shell|SHGetFolderLocation|Retrieves the PIDL of a folder. static PyObject *PySHGetFolderLocation(PyObject *self, PyObject *args) *************** *** 1256,1260 **** static PyObject *PySHGetDesktopFolder(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, ":SHGetPathFromIDList")) return NULL; IShellFolder *psf; --- 1295,1299 ---- static PyObject *PySHGetDesktopFolder(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, ":SHGetDesktopFolder")) return NULL; IShellFolder *psf; *************** *** 1274,1281 **** int index, imageIndex; if(!PyArg_ParseTuple(args, "Oiii:SHUpdateImage", ! &obHash, ! &index, ! &flags, ! &imageIndex)) return NULL; --- 1313,1320 ---- int index, imageIndex; if(!PyArg_ParseTuple(args, "Oiii:SHUpdateImage", ! &obHash, // @pyparm string|HashItem||Full path of file containing the icon as returned by <om PyIExtractIcon.GetIconLocation> ! &index, // @pyparm int|Index||Index of the icon in the above file ! &flags, // @pyparm int|Flags||GIL_NOTFILENAME or GIL_SIMULATEDOC ! &imageIndex)) // @pyparm int|ImageIndex||Index of the icon in the system image list return NULL; *************** *** 1298,1305 **** PyObject *ob1, *ob2 = Py_None; if(!PyArg_ParseTuple(args, "iiO|O:SHChangeNotify", ! &wEventID, ! &flags, ! &ob1, ! &ob2)) return NULL; --- 1337,1345 ---- PyObject *ob1, *ob2 = Py_None; if(!PyArg_ParseTuple(args, "iiO|O:SHChangeNotify", ! &wEventID, // @pyparm int|EventId||Combination of shellcon.SHCNE_* constants ! &flags, // @pyparm int|Flags||Combination of shellcon.SHCNF_* constants that specify type of last 2 parameters ! // Only one of the type flags may be specified, combined with one of the SHCNF_FLUSH* flags ! &ob1, // @pyparm object|Item1||Type is dependent on the event to be signalled ! &ob2)) // @pyparm object|Item2||Type is dependent on the event to be signalled return NULL; *************** *** 2070,2073 **** --- 2110,2114 ---- } + /* List of module functions */ // @module shell|A module, encapsulating the ActiveX Control interfaces *************** *** 2081,2085 **** { "SHGetFileInfo", PySHGetFileInfo, 1}, // @pymeth SHGetFileInfo|Retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root. { "SHGetFolderPath", PySHGetFolderPath, 1 }, // @pymeth SHGetFolderPath|Retrieves the path of a folder. ! { "SHGetFolderLocation", PySHGetFolderLocation, 1 }, // @pymeth SHGetFolderLocation|Retrieves the <o PyIDL> of a folder. { "SHGetSpecialFolderPath", PySHGetSpecialFolderPath, 1 }, // @pymeth SHGetSpecialFolderPath|Retrieves the path of a special folder. { "SHGetSpecialFolderLocation", PySHGetSpecialFolderLocation, 1 }, // @pymeth SHGetSpecialFolderLocation|Retrieves the <o PyIDL> of a special folder. --- 2122,2127 ---- { "SHGetFileInfo", PySHGetFileInfo, 1}, // @pymeth SHGetFileInfo|Retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root. { "SHGetFolderPath", PySHGetFolderPath, 1 }, // @pymeth SHGetFolderPath|Retrieves the path of a folder. ! { "SHSetFolderPath", PySHSetFolderPath, 1 }, // @pymeth SHSetFolderPath|Sets the location of a special folder ! { "SHGetFolderLocation", PySHGetFolderLocation, 1 }, // @pymeth SHGetFolderLocation|Retrieves the <o PyIDL> of a folder. { "SHGetSpecialFolderPath", PySHGetSpecialFolderPath, 1 }, // @pymeth SHGetSpecialFolderPath|Retrieves the path of a special folder. { "SHGetSpecialFolderLocation", PySHGetSpecialFolderLocation, 1 }, // @pymeth SHGetSpecialFolderLocation|Retrieves the <o PyIDL> of a special folder. *************** *** 2189,2193 **** --- 2231,2238 ---- pfnSHGetSettings = (PFNSHGetSettings)GetProcAddress(shell32, "SHGetSettings"); pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(shell32, "SHGetFolderPathW"); + // For some reason, SHSetFolderPath is only exported by ordinal SHSetFolderPathA is 231 + pfnSHSetFolderPath=(PFNSHSetFolderPath)GetProcAddress(shell32, (LPCSTR)232); pfnSHILCreateFromPath=(PFNSHILCreateFromPath)GetProcAddress(shell32, "SHILCreateFromPath"); + pfnSHShellFolderView_Message=(PFNSHShellFolderView_Message)GetProcAddress(shell32, "SHShellFolderView_Message"); } // SHGetFolderPath comes from shfolder.dll on older systems |
From: Roger U. <ru...@us...> - 2005-10-16 17:17:21
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10311/win32/Demos Added Files: SystemParametersInfo.py Log Message: Tests for most of the SystemParametersInfo actions --- NEW FILE: SystemParametersInfo.py --- import win32gui, win32con, win32api, time, os, glob ## some of these tests will fail for systems prior to XP for pname in( ## Set actions all take an unsigned int in pvParam "SPI_GETMOUSESPEED", "SPI_GETACTIVEWNDTRKTIMEOUT", "SPI_GETCARETWIDTH", "SPI_GETFOREGROUNDFLASHCOUNT", "SPI_GETFOREGROUNDLOCKTIMEOUT", ## Set actions all take an unsigned int in uiParam "SPI_GETWHEELSCROLLLINES", "SPI_GETKEYBOARDDELAY", "SPI_GETKEYBOARDSPEED", "SPI_GETMOUSEHOVERHEIGHT", "SPI_GETMOUSEHOVERWIDTH", "SPI_GETMOUSEHOVERTIME", "SPI_GETSCREENSAVETIMEOUT", "SPI_GETMENUSHOWDELAY", "SPI_GETLOWPOWERTIMEOUT", "SPI_GETPOWEROFFTIMEOUT", "SPI_GETBORDER", ## below are winxp only: "SPI_GETFONTSMOOTHINGCONTRAST", "SPI_GETFONTSMOOTHINGTYPE", "SPI_GETFOCUSBORDERHEIGHT", "SPI_GETFOCUSBORDERWIDTH", "SPI_GETMOUSECLICKLOCKTIME"): print pname cget=getattr(win32con,pname) cset=getattr(win32con,pname.replace('_GET','_SET')) orig_value=win32gui.SystemParametersInfo(cget) print '\toriginal setting:',orig_value win32gui.SystemParametersInfo(cset, orig_value+1) new_value=win32gui.SystemParametersInfo(cget) print '\tnew value:',new_value assert new_value==orig_value+1 win32gui.SystemParametersInfo(cset, orig_value) assert win32gui.SystemParametersInfo(cget)==orig_value # these take a boolean value in pvParam # change to opposite, check that it was changed and change back for pname in ("SPI_GETFLATMENU","SPI_GETDROPSHADOW","SPI_GETKEYBOARDCUES","SPI_GETMENUFADE", "SPI_GETCOMBOBOXANIMATION", "SPI_GETCURSORSHADOW", "SPI_GETGRADIENTCAPTIONS", "SPI_GETHOTTRACKING", "SPI_GETLISTBOXSMOOTHSCROLLING", "SPI_GETMENUANIMATION", "SPI_GETSELECTIONFADE", "SPI_GETTOOLTIPANIMATION", "SPI_GETTOOLTIPFADE", "SPI_GETUIEFFECTS", "SPI_GETACTIVEWINDOWTRACKING", "SPI_GETACTIVEWNDTRKZORDER"): print pname cget=getattr(win32con,pname) cset=getattr(win32con,pname.replace('_GET','_SET')) orig_value=win32gui.SystemParametersInfo(cget) print orig_value win32gui.SystemParametersInfo(cset, not orig_value) new_value=win32gui.SystemParametersInfo(cget) print new_value assert orig_value!=new_value win32gui.SystemParametersInfo(cset, orig_value) assert win32gui.SystemParametersInfo(cget)==orig_value # these take a boolean in uiParam # could combine with above section now that SystemParametersInfo only takes a single parameter for pname in ("SPI_GETFONTSMOOTHING","SPI_GETICONTITLEWRAP","SPI_GETBEEP","SPI_GETBLOCKSENDINPUTRESETS", "SPI_GETKEYBOARDPREF","SPI_GETSCREENSAVEACTIVE","SPI_GETMENUDROPALIGNMENT", "SPI_GETDRAGFULLWINDOWS", "SPI_GETSHOWIMEUI"): print pname cget=getattr(win32con,pname) cset=getattr(win32con,pname.replace('_GET','_SET')) orig_value=win32gui.SystemParametersInfo(cget) print orig_value win32gui.SystemParametersInfo(cset, not orig_value) new_value=win32gui.SystemParametersInfo(cget) print new_value assert orig_value!=new_value win32gui.SystemParametersInfo(cset, orig_value) assert win32gui.SystemParametersInfo(cget)==orig_value print "SPI_GETICONTITLELOGFONT" lf=win32gui.SystemParametersInfo(win32con.SPI_GETICONTITLELOGFONT) orig_height=lf.lfHeight orig_italic=lf.lfItalic print 'Height:', orig_height, 'Italic:',orig_italic lf.lfHeight+=2 lf.lfItalic=not lf.lfItalic win32gui.SystemParametersInfo(win32con.SPI_SETICONTITLELOGFONT, lf) new_lf=win32gui.SystemParametersInfo(win32con.SPI_GETICONTITLELOGFONT) print 'New Height:', new_lf.lfHeight, 'New Italic:',new_lf.lfItalic assert new_lf.lfHeight==orig_height+2 assert new_lf.lfItalic!=orig_italic lf.lfHeight=orig_height lf.lfItalic=orig_italic win32gui.SystemParametersInfo(win32con.SPI_SETICONTITLELOGFONT, lf) new_lf=win32gui.SystemParametersInfo(win32con.SPI_GETICONTITLELOGFONT) assert new_lf.lfHeight==orig_height assert new_lf.lfItalic==orig_italic print "SPI_GETMOUSEHOVERWIDTH, SPI_GETMOUSEHOVERHEIGHT, SPI_GETMOUSEHOVERTIME" w=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERWIDTH) h=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERHEIGHT) t=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERTIME) print 'w,h,t:', w,h,t win32gui.SystemParametersInfo(win32con.SPI_SETMOUSEHOVERWIDTH,w+1) win32gui.SystemParametersInfo(win32con.SPI_SETMOUSEHOVERHEIGHT,h+2) win32gui.SystemParametersInfo(win32con.SPI_SETMOUSEHOVERTIME,t+3) new_w=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERWIDTH) new_h=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERHEIGHT) new_t=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERTIME) print 'new w,h,t:', new_w, new_h, new_t assert new_w==w+1 assert new_h==h+2 assert new_t==t+3 win32gui.SystemParametersInfo(win32con.SPI_SETMOUSEHOVERWIDTH,w) win32gui.SystemParametersInfo(win32con.SPI_SETMOUSEHOVERHEIGHT,h) win32gui.SystemParametersInfo(win32con.SPI_SETMOUSEHOVERTIME,t) new_w=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERWIDTH) new_h=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERHEIGHT) new_t=win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERTIME) assert new_w==w assert new_h==h assert new_t==t print "SPI_SETDOUBLECLKWIDTH, SPI_SETDOUBLECLKHEIGHT" x=win32api.GetSystemMetrics(win32con.SM_CXDOUBLECLK) y=win32api.GetSystemMetrics(win32con.SM_CYDOUBLECLK) print 'x,y:', x, y win32gui.SystemParametersInfo(win32con.SPI_SETDOUBLECLKWIDTH, x+1) win32gui.SystemParametersInfo(win32con.SPI_SETDOUBLECLKHEIGHT, y+2) new_x=win32api.GetSystemMetrics(win32con.SM_CXDOUBLECLK) new_y=win32api.GetSystemMetrics(win32con.SM_CYDOUBLECLK) print 'new x,y:', new_x, new_y assert new_x==x+1 assert new_y==y+2 win32gui.SystemParametersInfo(win32con.SPI_SETDOUBLECLKWIDTH, x) win32gui.SystemParametersInfo(win32con.SPI_SETDOUBLECLKHEIGHT, y) new_x=win32api.GetSystemMetrics(win32con.SM_CXDOUBLECLK) new_y=win32api.GetSystemMetrics(win32con.SM_CYDOUBLECLK) assert new_x==x assert new_y==y print "SPI_SETDRAGWIDTH, SPI_SETDRAGHEIGHT" dw=win32api.GetSystemMetrics(win32con.SM_CXDRAG) dh=win32api.GetSystemMetrics(win32con.SM_CYDRAG) print 'dw,dh:', dw, dh win32gui.SystemParametersInfo(win32con.SPI_SETDRAGWIDTH,dw+1) win32gui.SystemParametersInfo(win32con.SPI_SETDRAGHEIGHT,dh+2) new_dw=win32api.GetSystemMetrics(win32con.SM_CXDRAG) new_dh=win32api.GetSystemMetrics(win32con.SM_CYDRAG) print 'new dw,dh:', new_dw, new_dh assert new_dw==dw+1 assert new_dh==dh+2 win32gui.SystemParametersInfo(win32con.SPI_SETDRAGWIDTH,dw) win32gui.SystemParametersInfo(win32con.SPI_SETDRAGHEIGHT,dh) new_dw=win32api.GetSystemMetrics(win32con.SM_CXDRAG) new_dh=win32api.GetSystemMetrics(win32con.SM_CYDRAG) assert new_dw==dw assert new_dh==dh orig_wallpaper=win32gui.SystemParametersInfo(Action=win32con.SPI_GETDESKWALLPAPER) print 'Original: ',orig_wallpaper for bmp in glob.glob(os.path.join(os.environ['windir'],'*.bmp')): print bmp win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, Param=bmp) print win32gui.SystemParametersInfo(Action=win32con.SPI_GETDESKWALLPAPER) time.sleep(1) win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, Param=orig_wallpaper) |
From: Roger U. <ru...@us...> - 2005-10-14 18:16:50
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11206/win32/src Modified Files: win32gui.i Log Message: Add SystemParametersInfo Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** win32gui.i 8 Oct 2005 07:20:34 -0000 1.70 --- win32gui.i 14 Oct 2005 18:16:40 -0000 1.71 *************** *** 14,19 **** %{ #define _WIN32_IE 0x0501 // to enable balloon notifications in Shell_NotifyIcon - #ifdef WINXPGUI #define _WIN32_WINNT 0x0501 // This changes the entire world for XP! #define ISOLATION_AWARE_ENABLED 1 --- 14,19 ---- %{ #define _WIN32_IE 0x0501 // to enable balloon notifications in Shell_NotifyIcon #define _WIN32_WINNT 0x0501 + #ifdef WINXPGUI // This changes the entire world for XP! #define ISOLATION_AWARE_ENABLED 1 *************** *** 116,122 **** #endif if (strcmp(pmd->ml_name, "GetOpenFileNameW")==0 || ! strcmp(pmd->ml_name, "GetSaveFileNameW")==0) pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; ! %} --- 116,123 ---- #endif if (strcmp(pmd->ml_name, "GetOpenFileNameW")==0 || ! strcmp(pmd->ml_name, "GetSaveFileNameW")==0 || ! strcmp(pmd->ml_name, "SystemParametersInfo")==0) pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; ! %} *************** *** 3876,3877 **** --- 3877,4460 ---- PyCFunction pfnPyGetOpenFileNameW=(PyCFunction)PyGetOpenFileNameW; %} + + %native (SystemParametersInfo) pfnPySystemParametersInfo; + // @pyswig |SystemParametersInfo|Queries or sets system-wide parameters. This function can also update the user profile while setting a parameter. + // @rdesc SPI_SET functions all return None on success. Types returned by SPI_GET functions are dependent on the operation + // @comm Param and WinIni are not used with any of the SPI_GET operations<nl> + // Boolean parameters can be any object that can be evaluated as True or False + %{ + BOOL PyObject_AsUINT(PyObject *ob, UINT *puint) + { + // PyLong_AsUnsignedLong throws a bogus error in 2.3 if passed an int, and there is no PyInt_AsUnsignedLong + // ref: http://mail.python.org/pipermail/patches/2004-September/016060.html + // And for some reason none of the Unsigned*Mask functions check for overflow ??? + + __int64 UINT_candidate=PyLong_AsLongLong(ob); + if (UINT_candidate==-1 && PyErr_Occurred()) + return FALSE; + if (UINT_candidate<0 || UINT_candidate>UINT_MAX){ + PyErr_Format(PyExc_ValueError, "Parameter must be in range 0 - %d", UINT_MAX); + return FALSE; + } + *puint=(UINT)UINT_candidate; + return TRUE; + } + + static PyObject *PySystemParametersInfo(PyObject *self, PyObject *args, PyObject *kwargs) + { + static char *keywords[]={"Action", "Param", "WinIni", NULL}; + UINT Action, uiParam=0, WinIni=0; + PVOID pvParam=NULL; + PyObject *obParam=Py_None, *ret=NULL; + DWORD buflen; + BOOL boolParam; + UINT uintParam; + long longParam; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "k|Ok", keywords, + &Action, // @pyparm int|Action||System parameter to query or set, one of the SPI_GET* or SPI_SET* constants + &obParam, // @pyparm object|Param|None|depends on action to be taken + &WinIni)) // @pyparm int|WinIni|0|Flags specifying whether change should be permanent, and if all windows should be notified of change. Combination of SPIF_UPDATEINIFILE, SPIF_SENDCHANGE, SPIF_SENDWININICHANGE + return NULL; + + // @flagh Action|Input/return type + switch (Action){ + // @flag SPI_GETDESKWALLPAPER|Returns the path to the bmp used as wallpaper + case SPI_GETDESKWALLPAPER: + uiParam=MAX_PATH; + buflen=uiParam*sizeof(TCHAR); + pvParam=malloc(buflen); + if (pvParam==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", buflen); + goto done; + } + break; + // @flag SPI_SETDESKWALLPAPER|Param should be a string specifying a .bmp file + case SPI_SETDESKWALLPAPER: + if (!PyWinObject_AsTCHAR(obParam, (TCHAR **)&pvParam, TRUE, &buflen)) + goto done; + uiParam=buflen; + break; + + // Below actions return a boolean pointed to by Param + // @flag SPI_GETDROPSHADOW|Returns a boolean + case SPI_GETDROPSHADOW: + // @flag SPI_GETFLATMENU|Returns a boolean + case SPI_GETFLATMENU: + // @flag SPI_GETFONTSMOOTHING|Returns a boolean + case SPI_GETFONTSMOOTHING: + // @flag SPI_GETICONTITLEWRAP|Returns a boolean + case SPI_GETICONTITLEWRAP: + // @flag SPI_GETSNAPTODEFBUTTON|Returns a boolean + case SPI_GETSNAPTODEFBUTTON: + // @flag SPI_GETBEEP|Returns a boolean + case SPI_GETBEEP: + // @flag SPI_GETBLOCKSENDINPUTRESETS|Returns a boolean + case SPI_GETBLOCKSENDINPUTRESETS: + // @flag SPI_GETMENUUNDERLINES|Returns a boolean + // @flag SPI_GETKEYBOARDCUES|Returns a boolean + case SPI_GETKEYBOARDCUES: + // @flag SPI_GETKEYBOARDPREF|Returns a boolean + case SPI_GETKEYBOARDPREF: + // @flag SPI_GETSCREENSAVEACTIVE|Returns a boolean + case SPI_GETSCREENSAVEACTIVE: + // @flag SPI_GETSCREENSAVERRUNNING|Returns a boolean + case SPI_GETSCREENSAVERRUNNING: + // @flag SPI_GETMENUDROPALIGNMENT|Returns a boolean (True indicates left aligned, False right aligned) + case SPI_GETMENUDROPALIGNMENT: + // @flag SPI_GETMENUFADE|Returns a boolean + case SPI_GETMENUFADE: + // @flag SPI_GETLOWPOWERACTIVE|Returns a boolean + case SPI_GETLOWPOWERACTIVE: + // @flag SPI_GETPOWEROFFACTIVE|Returns a boolean + case SPI_GETPOWEROFFACTIVE: + // @flag SPI_GETCOMBOBOXANIMATION|Returns a boolean + case SPI_GETCOMBOBOXANIMATION: + // @flag SPI_GETCURSORSHADOW|Returns a boolean + case SPI_GETCURSORSHADOW: + // @flag SPI_GETGRADIENTCAPTIONS|Returns a boolean + case SPI_GETGRADIENTCAPTIONS: + // @flag SPI_GETHOTTRACKING|Returns a boolean + case SPI_GETHOTTRACKING: + // @flag SPI_GETLISTBOXSMOOTHSCROLLING|Returns a boolean + case SPI_GETLISTBOXSMOOTHSCROLLING: + // @flag SPI_GETMENUANIMATION|Returns a boolean + case SPI_GETMENUANIMATION: + // @flag SPI_GETSELECTIONFADE|Returns a boolean + case SPI_GETSELECTIONFADE: + // @flag SPI_GETTOOLTIPANIMATION|Returns a boolean + case SPI_GETTOOLTIPANIMATION: + // @flag SPI_GETTOOLTIPFADE|Returns a boolean (TRUE=fade, False=slide) + case SPI_GETTOOLTIPFADE: + // @flag SPI_GETUIEFFECTS|Returns a boolean + case SPI_GETUIEFFECTS: + // @flag SPI_GETACTIVEWINDOWTRACKING|Returns a boolean + case SPI_GETACTIVEWINDOWTRACKING: + // @flag SPI_GETACTIVEWNDTRKZORDER|Returns a boolean + case SPI_GETACTIVEWNDTRKZORDER: + // @flag SPI_GETDRAGFULLWINDOWS|Returns a boolean + case SPI_GETDRAGFULLWINDOWS: + // @flag SPI_GETSHOWIMEUI|Returns a boolean + case SPI_GETSHOWIMEUI: + // @flag SPI_GETMOUSECLICKLOCK|Returns a boolean + case SPI_GETMOUSECLICKLOCK: + // @flag SPI_GETMOUSESONAR|Returns a boolean + case SPI_GETMOUSESONAR: + // @flag SPI_GETMOUSEVANISH|Returns a boolean + case SPI_GETMOUSEVANISH: + // @flag SPI_GETSCREENREADER|Returns a boolean + case SPI_GETSCREENREADER: + // @flag SPI_GETSHOWSOUNDS|Returns a boolean + case SPI_GETSHOWSOUNDS: + pvParam=&boolParam; + break; + + // Actions in this section accept a boolean as pvParam + // @flag SPI_SETDROPSHADOW|Param must be a boolean + case SPI_SETDROPSHADOW: + // @flag SPI_SETDROPSHADOW|Param must be a boolean + case SPI_SETFLATMENU: + // @flag SPI_SETMENUUNDERLINES|Param must be a boolean + // @flag SPI_SETKEYBOARDCUES|Param must be a boolean + case SPI_SETKEYBOARDCUES: + // @flag SPI_SETMENUFADE|Param must be a boolean + case SPI_SETMENUFADE: + // @flag SPI_SETCOMBOBOXANIMATION|Param must be a boolean + case SPI_SETCOMBOBOXANIMATION: + // @flag SPI_SETCURSORSHADOW|Param must be a boolean + case SPI_SETCURSORSHADOW: + // @flag SPI_SETGRADIENTCAPTIONS|Param must be a boolean + case SPI_SETGRADIENTCAPTIONS: + // @flag SPI_SETHOTTRACKING|Param must be a boolean + case SPI_SETHOTTRACKING: + // @flag SPI_SETLISTBOXSMOOTHSCROLLING|Param must be a boolean + case SPI_SETLISTBOXSMOOTHSCROLLING: + // @flag SPI_SETMENUANIMATION|Param must be a boolean + case SPI_SETMENUANIMATION: + // @flag SPI_SETSELECTIONFADE|Param must be a boolean + case SPI_SETSELECTIONFADE: + // @flag SPI_SETTOOLTIPANIMATION|Param must be a boolean + case SPI_SETTOOLTIPANIMATION: + // @flag SPI_SETTOOLTIPFADE|Param must be a boolean + case SPI_SETTOOLTIPFADE: + // @flag SPI_SETUIEFFECTS|Param must be a boolean + case SPI_SETUIEFFECTS: + // @flag SPI_SETACTIVEWINDOWTRACKING|Param must be a boolean + case SPI_SETACTIVEWINDOWTRACKING: + // @flag SPI_SETACTIVEWNDTRKZORDER|Param must be a boolean + case SPI_SETACTIVEWNDTRKZORDER: + // @flag SPI_SETMOUSESONAR|Param must be a boolean + case SPI_SETMOUSESONAR: + // @flag SPI_SETMOUSEVANISH|Param must be a boolean + case SPI_SETMOUSEVANISH: + // @flag SPI_SETMOUSECLICKLOCK|Param must be a boolean + case SPI_SETMOUSECLICKLOCK: + pvParam=(PVOID)PyObject_IsTrue(obParam); + if (pvParam==(PVOID)-1) + goto done; + break; + + // These accept a boolean placed in uiParam + // @flag SPI_SETFONTSMOOTHING|Param should specify a boolean + case SPI_SETFONTSMOOTHING: + // @flag SPI_SETICONTITLEWRAP|Param should specify a boolean + case SPI_SETICONTITLEWRAP: + // @flag SPI_SETSNAPTODEFBUTTON|Param is a boolean + case SPI_SETSNAPTODEFBUTTON: + // @flag SPI_SETBEEP|Param is a boolean + case SPI_SETBEEP: + // @flag SPI_SETBLOCKSENDINPUTRESETS|Param is a boolean + case SPI_SETBLOCKSENDINPUTRESETS: + // @flag SPI_SETKEYBOARDPREF|Param is a boolean + case SPI_SETKEYBOARDPREF: + // @flag SPI_SETMOUSEBUTTONSWAP|Param is a boolean + case SPI_SETMOUSEBUTTONSWAP: + // @flag SPI_SETSCREENSAVEACTIVE|Param is a boolean + case SPI_SETSCREENSAVEACTIVE: + // @flag SPI_SETMENUDROPALIGNMENT|Param is a boolean (True=left aligned, False=right aligned) + case SPI_SETMENUDROPALIGNMENT: + // @flag SPI_SETLOWPOWERACTIVE|Param is a boolean + case SPI_SETLOWPOWERACTIVE: + // @flag SPI_SETPOWEROFFACTIVE|Param is a boolean + case SPI_SETPOWEROFFACTIVE: + // @flag SPI_SETDRAGFULLWINDOWS|Param is a boolean + case SPI_SETDRAGFULLWINDOWS: + // @flag SPI_SETSHOWIMEUI|Param is a boolean + case SPI_SETSHOWIMEUI: + // @flag SPI_SETSCREENREADER|Param is a boolean + case SPI_SETSCREENREADER: + // @flag SPI_SETSHOWSOUNDS|Param is a boolean + case SPI_SETSHOWSOUNDS: + uiParam=(UINT)PyObject_IsTrue(obParam); + if (uiParam==(UINT)-1) + goto done; + break; + + // These accept an int placed in uiParam + // @flag SPI_SETMOUSETRAILS|Param should be an int specifying the nbr of cursors in the trail (0 or 1 means disabled) + case SPI_SETMOUSETRAILS: + // @flag SPI_SETWHEELSCROLLLINES|Param is an int specifying nbr of lines + case SPI_SETWHEELSCROLLLINES: + // @flag SPI_SETKEYBOARDDELAY|Param is an int in the range 0 - 3 + case SPI_SETKEYBOARDDELAY: + // @flag SPI_SETKEYBOARDSPEED|Param is an int in the range 0 - 31 + case SPI_SETKEYBOARDSPEED: + // @flag SPI_SETDOUBLECLICKTIME|Param is an int (in milliseconds), Use <om win32gui.GetDoubleClickTime> to retrieve the value. + case SPI_SETDOUBLECLICKTIME: + // @flag SPI_SETDOUBLECLKWIDTH|Param is an int. Use win32api.GetSystemMetrics(SM_CXDOUBLECLK) to retrieve the value. + case SPI_SETDOUBLECLKWIDTH: + // @flag SPI_SETDOUBLECLKHEIGHT|Param is an int, Use win32api.GetSystemMetrics(SM_CYDOUBLECLK) to retrieve the value. + case SPI_SETDOUBLECLKHEIGHT: + // @flag SPI_SETMOUSEHOVERHEIGHT|Param is an int + case SPI_SETMOUSEHOVERHEIGHT: + // @flag SPI_SETMOUSEHOVERWIDTH|Param is an int + case SPI_SETMOUSEHOVERWIDTH: + // @flag SPI_SETMOUSEHOVERTIME|Param is an int + case SPI_SETMOUSEHOVERTIME: + // @flag SPI_SETSCREENSAVETIMEOUT|Param is an int specifying the timeout in seconds + case SPI_SETSCREENSAVETIMEOUT: + // @flag SPI_SETMENUSHOWDELAY|Param is an int specifying the shortcut menu delay in milliseconds + case SPI_SETMENUSHOWDELAY: + // @flag SPI_SETLOWPOWERTIMEOUT|Param is an int (in seconds) + case SPI_SETLOWPOWERTIMEOUT: + // @flag SPI_SETPOWEROFFTIMEOUT|Param is an int (in seconds) + case SPI_SETPOWEROFFTIMEOUT: + // @flag SPI_SETDRAGHEIGHT|Param is an int. Use win32api.GetSystemMetrics(SM_CYDRAG) to retrieve the value. + case SPI_SETDRAGHEIGHT: + // @flag SPI_SETDRAGWIDTH|Param is an int. Use win32api.GetSystemMetrics(SM_CXDRAG) to retrieve the value. + case SPI_SETDRAGWIDTH: + // @flag SPI_SETBORDER|Param is an int + case SPI_SETBORDER: + if (!PyObject_AsUINT(obParam, &uiParam)) + goto done; + break; + + // below Actions all return a UINT pointed to by Param + // @flag SPI_GETFONTSMOOTHINGCONTRAST|Returns an int + case SPI_GETFONTSMOOTHINGCONTRAST: + // @flag SPI_GETFONTSMOOTHINGTYPE|Returns an int + case SPI_GETFONTSMOOTHINGTYPE: + // @flag SPI_GETMOUSETRAILS|Returns an int specifying the nbr of cursor images in the trail, 0 or 1 indicates disabled + case SPI_GETMOUSETRAILS: + // @flag SPI_GETWHEELSCROLLLINES|Returns the nbr of lines to scroll for the mouse wheel + case SPI_GETWHEELSCROLLLINES: + // @flag SPI_GETKEYBOARDDELAY|Returns an int + case SPI_GETKEYBOARDDELAY: + // @flag SPI_GETKEYBOARDSPEED|Returns an int + case SPI_GETKEYBOARDSPEED: + // @flag SPI_GETMOUSESPEED|Returns an int + case SPI_GETMOUSESPEED: + // @flag SPI_GETMOUSEHOVERHEIGHT|Returns an int + case SPI_GETMOUSEHOVERHEIGHT: + // @flag SPI_GETMOUSEHOVERWIDTH|Returns an int + case SPI_GETMOUSEHOVERWIDTH: + // @flag SPI_GETMOUSEHOVERTIME|Returns an int + case SPI_GETMOUSEHOVERTIME: + // @flag SPI_GETSCREENSAVETIMEOUT|Returns an int (idle time in seconds) + case SPI_GETSCREENSAVETIMEOUT: + // @flag SPI_GETMENUSHOWDELAY|Returns an int (shortcut delay in milliseconds) + case SPI_GETMENUSHOWDELAY: + // @flag SPI_GETLOWPOWERTIMEOUT|Returns an int (in seconds) + case SPI_GETLOWPOWERTIMEOUT: + // @flag SPI_GETPOWEROFFTIMEOUT|Returns an int (in seconds) + case SPI_GETPOWEROFFTIMEOUT: + // @flag SPI_GETACTIVEWNDTRKTIMEOUT|Returns an int (milliseconds) + case SPI_GETACTIVEWNDTRKTIMEOUT: + // @flag SPI_GETBORDER|Returns an int + case SPI_GETBORDER: + // @flag SPI_GETCARETWIDTH|Returns an int + case SPI_GETCARETWIDTH: + // @flag SPI_GETFOREGROUNDFLASHCOUNT|Returns an int + case SPI_GETFOREGROUNDFLASHCOUNT: + // @flag SPI_GETFOREGROUNDLOCKTIMEOUT|Returns an int + case SPI_GETFOREGROUNDLOCKTIMEOUT: + // @flag SPI_GETFOCUSBORDERHEIGHT|Returns an int + case SPI_GETFOCUSBORDERHEIGHT: + // @flag SPI_GETFOCUSBORDERWIDTH|Returns an int + case SPI_GETFOCUSBORDERWIDTH: + // @flag SPI_GETMOUSECLICKLOCKTIME|Returns an int (in milliseconds) + case SPI_GETMOUSECLICKLOCKTIME: + pvParam=&uintParam; + break; + + // Actions that take pvParam as an unsigned int + // @flag SPI_SETFONTSMOOTHINGCONTRAST|Param should be an int in the range 1000 to 2200 + case SPI_SETFONTSMOOTHINGCONTRAST: + // @flag SPI_SETFONTSMOOTHINGTYPE|Param should be one of the FE_FONTSMOOTHING* constants + case SPI_SETFONTSMOOTHINGTYPE: + // @flag SPI_SETMOUSESPEED|Param should be an int in the range 1 - 20 + case SPI_SETMOUSESPEED: + // @flag SPI_SETACTIVEWNDTRKTIMEOUT|Param is an int (in milliseconds) + case SPI_SETACTIVEWNDTRKTIMEOUT: + // @flag SPI_SETCARETWIDTH|Param is an int (in pixels) + case SPI_SETCARETWIDTH: + // @flag SPI_SETFOREGROUNDFLASHCOUNT|Param is an int + case SPI_SETFOREGROUNDFLASHCOUNT: + // @flag SPI_SETFOREGROUNDLOCKTIMEOUT|Param is an int (in milliseconds) + case SPI_SETFOREGROUNDLOCKTIMEOUT: + // @flag SPI_SETFOCUSBORDERHEIGHT|Returns an int + case SPI_SETFOCUSBORDERHEIGHT: + // @flag SPI_SETFOCUSBORDERWIDTH|Returns an int + case SPI_SETFOCUSBORDERWIDTH: + // @flag SPI_SETMOUSECLICKLOCKTIME|Param is an int (in milliseconds) + case SPI_SETMOUSECLICKLOCKTIME: + if (!PyObject_AsUINT(obParam, (UINT *)&pvParam)) + goto done; + break; + + // @flag SPI_GETICONTITLELOGFONT|Returns a <o PyLOGFONT>, + case SPI_GETICONTITLELOGFONT: + uiParam=sizeof(LOGFONT); + pvParam=malloc(uiParam); + if (pvParam==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d bytes", uiParam); + goto done; + } + break; + // @flag SPI_SETICONTITLELOGFONT|Param must be a <o PyLOGFONT>, + case SPI_SETICONTITLELOGFONT: + if (!PyLOGFONT_Check(obParam)){ + PyErr_SetString(PyExc_TypeError, "Param must be a LOGFONT"); + goto done; + } + pvParam=((PyLOGFONT *)obParam)->GetLF(); + uiParam=sizeof(LOGFONT); + break; + + + // Set operations that take no parameter + // @flag SPI_SETLANGTOGGLE|Param is ignored. Sets the language toggle hotkey from registry key HKCU\keyboard layout\toggle + case SPI_SETLANGTOGGLE: + // @flag SPI_SETICONS|Reloads the system icons. Param is not used + case SPI_SETICONS: + break; + + // @flag SPI_GETMOUSE|Returns a tuple of 3 ints containing the x and y mouse thresholds and the acceleration factor. + case SPI_GETMOUSE: + // @flag SPI_SETMOUSE|Param should be a sequence of 3 ints + case SPI_SETMOUSE:{ + buflen=3*sizeof(UINT); + pvParam=malloc(buflen); + if (pvParam==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d bytes", buflen); + goto done; + } + if (Action==SPI_SETMOUSE){ + PyObject *param_tuple=PySequence_Tuple(obParam); + if (param_tuple==NULL) + goto done; + if (PyTuple_GET_SIZE(param_tuple) != 3){ + PyErr_SetString(PyExc_ValueError,"Param must be a sequence of 3 ints"); + Py_DECREF(param_tuple); + goto done; + } + if (!PyArg_ParseTuple(param_tuple, "kkk", &((UINT *)pvParam)[0], &((UINT *)pvParam)[1], &((UINT *)pvParam)[2])){ + Py_DECREF(param_tuple); + goto done; + } + Py_DECREF(param_tuple); + } + break; + } + + // @flag SPI_GETDEFAULTINPUTLANG|Returns an int (locale id for default language) + case SPI_GETDEFAULTINPUTLANG: + pvParam=&longParam; + break; + // @flag SPI_SETDEFAULTINPUTLANG|Param is an int containing a locale id + case SPI_SETDEFAULTINPUTLANG: + // input is a HKL, which is actually a HANDLE, which can be treated as a long + longParam=PyInt_AsLong(obParam); + if (longParam==-1 && PyErr_Occurred()) + goto done; + pvParam=&longParam; + break; + // @flag SPI_GETANIMATION|Returns an int + case SPI_GETANIMATION: + // @flag SPI_SETANIMATION|Param is an int + case SPI_SETANIMATION: + buflen=sizeof(ANIMATIONINFO); + pvParam=malloc(buflen); + if (pvParam==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d bytes", buflen); + goto done; + } + ZeroMemory(pvParam, buflen); + uiParam=buflen; + ((ANIMATIONINFO *)pvParam)->cbSize=buflen; + if (Action==SPI_SETANIMATION){ + ((ANIMATIONINFO *)pvParam)->iMinAnimate=PyInt_AsLong(obParam); + if (((ANIMATIONINFO *)pvParam)->iMinAnimate==-1 && PyErr_Occurred()) + goto done; + } + break; + // @flag SPI_ICONHORIZONTALSPACING|Functions as both a get and set operation. If Param is None, functions as a get operation, otherwise Param is an int to be set as the new value + case SPI_ICONHORIZONTALSPACING: + // @flag SPI_ICONVERTICALSPACING|Functions as both a get and set operation. If Param is None, functions as a get operation, otherwise Param is an int to be set as the new value + case SPI_ICONVERTICALSPACING: + if (obParam==Py_None) // indicates a get operation + pvParam=&uintParam; + else // for set operation, value is passed in uiParam + if (!PyObject_AsUINT(obParam, &uiParam)) + goto done; + break; + + // below are not handled yet + // @flag SPI_SETDESKPATTERN|Unsupported (obsolete) + // @flag SPI_GETFASTTASKSWITCH|Unsupported (obsolete) + // @flag SPI_SETFASTTASKSWITCH|Unsupported (obsolete) + // @flag SPI_SETSCREENSAVERRUNNING|Unsupported (documented as internal use only) + // @flag SPI_SCREENSAVERRUNNING|Same as SPI_SETSCREENSAVERRUNNING + // @flag SPI_SETPENWINDOWS|Unsupported (only relevant for win95) + // @flag SPI_GETWINDOWSEXTENSION|Unsupported (only relevant for win95) + // @flag SPI_GETGRIDGRANULARITY|Unsupported (obsolete) + // @flag SPI_SETGRIDGRANULARITY|Unsupported (obsolete) + // @flag SPI_LANGDRIVER|Unsupported (use is not documented) + // @flag SPI_GETFONTSMOOTHINGORIENTATION|Unsupported (use is not documented) + // @flag SPI_SETFONTSMOOTHINGORIENTATION|Unsupported (use is not documented) + // @flag SPI_SETHANDHELD|Unsupported (use is not documented) + // @flag SPI_GETMINIMIZEDMETRICS|Not implemented yet + // @flag SPI_SETMINIMIZEDMETRICS|Not implemented yet + // @flag SPI_GETNONCLIENTMETRICS|Not implemented yet + // @flag SPI_SETNONCLIENTMETRICS|Not implemented yet + // @flag SPI_GETICONMETRICS|Not implemented yet + // @flag SPI_SETICONMETRICS|Not implemented yet + // @flag SPI_GETWORKAREA|Not implemented yet + // @flag SPI_SETWORKAREA|Not implemented yet + // @flag SPI_GETSERIALKEYS|Not implemented yet + // @flag SPI_SETSERIALKEYS|Not implemented yet + // @flag SPI_SETMOUSEKEYS|Not implemented yet + // @flag SPI_GETMOUSEKEYS|Not implemented yet + // @flag SPI_GETHIGHCONTRAST|Not implemented yet + // @flag SPI_SETHIGHCONTRAST|Not implemented yet + // @flag SPI_GETSOUNDSENTRY|Not implemented yet + // @flag SPI_SETSOUNDSENTRY|Not implemented yet + // @flag SPI_GETSTICKYKEYS|Not implemented yet + // @flag SPI_SETSTICKYKEYS|Not implemented yet + // @flag SPI_GETTOGGLEKEYS|Not implemented yet + // @flag SPI_SETTOGGLEKEYS|Not implemented yet + // @flag SPI_GETACCESSTIMEOUT|Not implemented yet + // @flag SPI_SETACCESSTIMEOUT|Not implemented yet + // @flag SPI_GETFILTERKEYS|Not implemented yet + // @flag SPI_SETFILTERKEYS|Not implemented yet + default: + PyErr_Format(PyExc_NotImplementedError, "Action %d is not supported yet", Action); + goto done; + } + + if (!SystemParametersInfo(Action, uiParam, pvParam, WinIni)){ + PyWin_SetAPIError("SystemParametersInfo"); + goto done; + } + + switch (Action){ + case SPI_GETDESKWALLPAPER: + ret=PyWinObject_FromTCHAR((TCHAR *)pvParam); + break; + case SPI_GETDROPSHADOW: + case SPI_GETFLATMENU: + case SPI_GETFONTSMOOTHING: + case SPI_GETICONTITLEWRAP: + case SPI_GETSNAPTODEFBUTTON: + case SPI_GETBEEP: + case SPI_GETBLOCKSENDINPUTRESETS: + case SPI_GETKEYBOARDCUES: + case SPI_GETKEYBOARDPREF: + case SPI_GETSCREENSAVEACTIVE: + case SPI_GETSCREENSAVERRUNNING: + case SPI_GETMENUDROPALIGNMENT: + case SPI_GETMENUFADE: + case SPI_GETLOWPOWERACTIVE: + case SPI_GETPOWEROFFACTIVE: + case SPI_GETCOMBOBOXANIMATION: + case SPI_GETCURSORSHADOW: + case SPI_GETGRADIENTCAPTIONS: + case SPI_GETHOTTRACKING: + case SPI_GETLISTBOXSMOOTHSCROLLING: + case SPI_GETMENUANIMATION: + case SPI_GETSELECTIONFADE: + case SPI_GETTOOLTIPANIMATION: + case SPI_GETTOOLTIPFADE: + case SPI_GETUIEFFECTS: + case SPI_GETACTIVEWINDOWTRACKING: + case SPI_GETACTIVEWNDTRKZORDER: + case SPI_GETDRAGFULLWINDOWS: + case SPI_GETSHOWIMEUI: + case SPI_GETMOUSECLICKLOCK: + case SPI_GETMOUSESONAR: + case SPI_GETMOUSEVANISH: + case SPI_GETSCREENREADER: + case SPI_GETSHOWSOUNDS: + ret=PyBool_FromLong(boolParam); + break; + case SPI_GETFONTSMOOTHINGCONTRAST: + case SPI_GETFONTSMOOTHINGTYPE: + case SPI_GETMOUSETRAILS: + case SPI_GETWHEELSCROLLLINES: + case SPI_GETKEYBOARDDELAY: + case SPI_GETKEYBOARDSPEED: + case SPI_GETMOUSESPEED: + case SPI_GETMOUSEHOVERHEIGHT: + case SPI_GETMOUSEHOVERWIDTH: + case SPI_GETMOUSEHOVERTIME: + case SPI_GETSCREENSAVETIMEOUT: + case SPI_GETMENUSHOWDELAY: + case SPI_GETLOWPOWERTIMEOUT: + case SPI_GETPOWEROFFTIMEOUT: + case SPI_GETACTIVEWNDTRKTIMEOUT: + case SPI_GETBORDER: + case SPI_GETCARETWIDTH: + case SPI_GETFOREGROUNDFLASHCOUNT: + case SPI_GETFOREGROUNDLOCKTIMEOUT: + case SPI_GETFOCUSBORDERHEIGHT: + case SPI_GETFOCUSBORDERWIDTH: + case SPI_GETMOUSECLICKLOCKTIME: + ret=PyLong_FromUnsignedLong(uintParam); + break; + case SPI_GETDEFAULTINPUTLANG: + ret=PyLong_FromLong(longParam); + break; + case SPI_GETICONTITLELOGFONT: + ret=new PyLOGFONT((LOGFONT *)pvParam); + break; + case SPI_GETMOUSE: + ret=Py_BuildValue("kkk", ((UINT *)pvParam)[0], ((UINT *)pvParam)[1], ((UINT *)pvParam)[2]); + break; + case SPI_GETANIMATION: + ret=PyInt_FromLong(((ANIMATIONINFO *)pvParam)->iMinAnimate); + break; + // these 2 can be a get or set, use Param==Py_None to mean a get + case SPI_ICONHORIZONTALSPACING: + case SPI_ICONVERTICALSPACING: + if (obParam==Py_None) + ret=PyLong_FromUnsignedLong(uintParam); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + break; + + default: + Py_INCREF(Py_None); + ret=Py_None; + } + + done: + switch (Action){ + case SPI_GETDESKWALLPAPER: + case SPI_GETICONTITLELOGFONT: + case SPI_GETMOUSE: + case SPI_SETMOUSE: + case SPI_GETANIMATION: + case SPI_SETANIMATION: + if (pvParam!=NULL) + free(pvParam); + break; + case SPI_SETDESKWALLPAPER: + PyWinObject_FreeTCHAR((TCHAR *)pvParam); + break; + } + return ret; + } + PyCFunction pfnPySystemParametersInfo=(PyCFunction)PySystemParametersInfo; + %} |
From: Roger U. <ru...@us...> - 2005-10-10 14:11:03
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27240/com/win32com/src/extensions Modified Files: PyIEnumSTATSTG.cpp Log Message: Fix memory leak in PyIEnumSTATSTG.Next Index: PyIEnumSTATSTG.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIEnumSTATSTG.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIEnumSTATSTG.cpp 2 Nov 2003 09:57:44 -0000 1.4 --- PyIEnumSTATSTG.cpp 10 Oct 2005 14:11:01 -0000 1.5 *************** *** 41,83 **** STATSTG *rgVar = new STATSTG[celt]; ! if ( rgVar == NULL ) { ! PyErr_SetString(PyExc_MemoryError, "allocating result STATSTGs"); ! return NULL; ! } int i; - /* for ( i = celt; i--; ) - // *** possibly init each structure element??? - */ - ULONG celtFetched; PY_INTERFACE_PRECALL; HRESULT hr = pIESTATSTG->Next(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) ! { ! delete [] rgVar; ! return PyCom_BuildPyException(hr); ! } ! ! PyObject *result = PyTuple_New(celtFetched); ! if ( result != NULL ) ! { ! for ( i = celtFetched; i--; ) ! { ! PyObject *ob = PyCom_PyObjectFromSTATSTG(&rgVar[i]); ! if ( ob == NULL ) { ! Py_DECREF(result); ! result = NULL; ! break; } - PyTuple_SET_ITEM(result, i, ob); } } ! /* for ( i = celtFetched; i--; ) ! // *** possibly cleanup each structure element??? ! */ delete [] rgVar; return result; --- 41,78 ---- STATSTG *rgVar = new STATSTG[celt]; ! if ( rgVar == NULL ) ! return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", celt*sizeof(STATSTG)); ! ZeroMemory(rgVar, celt*sizeof(STATSTG)); int i; ULONG celtFetched; + PyObject *result; + PY_INTERFACE_PRECALL; HRESULT hr = pIESTATSTG->Next(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) ! result=PyCom_BuildPyException(hr); ! else{ ! result = PyTuple_New(celtFetched); ! if ( result != NULL ){ ! for ( i = celtFetched; i--; ) { ! PyObject *ob = PyCom_PyObjectFromSTATSTG(&rgVar[i]); ! if ( ob == NULL ) ! { ! Py_DECREF(result); ! result = NULL; ! break; ! } ! PyTuple_SET_ITEM(result, i, ob); } } } ! for ( i = celtFetched; i--; ) ! if (rgVar[i].pwcsName!=NULL) ! CoTaskMemFree(rgVar[i].pwcsName); ! delete [] rgVar; return result; |
From: Roger U. <ru...@us...> - 2005-10-09 09:47:14
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7679/win32/src Modified Files: win32apimodule.cpp Log Message: Add GetKeyboardLayoutList and LoadKeyboardLayout Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** win32apimodule.cpp 28 Jun 2005 12:34:37 -0000 1.49 --- win32apimodule.cpp 9 Oct 2005 09:47:06 -0000 1.50 *************** *** 4622,4625 **** --- 4622,4676 ---- } + // @pymethod (int,..)|win32api|GetKeyboardLayoutList|Returns a sequence of all locale ids currently loaded + PyObject *PyGetKeyboardLayoutList(PyObject *self, PyObject *args) + { + int buflen; + HKL *buf; + PyObject *ret=NULL; + if (!PyArg_ParseTuple(args,":GetKeyboardLayoutList")) + return NULL; + buflen=GetKeyboardLayoutList(0,NULL); + buf=(HKL *)malloc(buflen*sizeof(HKL)); + if (buf==NULL) + return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", buflen*sizeof(HKL)); + buflen=GetKeyboardLayoutList(buflen, buf); + if (buflen==0) + PyWin_SetAPIError("GetKeyboardLayout"); + else{ + ret=PyTuple_New(buflen); + 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); + ret=NULL; + break; + } + PyTuple_SET_ITEM(ret, tuple_ind, tuple_item); + } + } + } + free(buf); + return ret; + } + + // @pymethod int|win32api|LoadKeyboardLayout|Loads a new locale id + // @rdesc Returns the numeric locale id that was loaded + PyObject *PyLoadKeyboardLayout(PyObject *self, PyObject *args) + { + char *lcid_str; + HKL lcid; + UINT flags=0; + if (!PyArg_ParseTuple(args, "s|k:LoadKeyboardLayout", + &lcid_str, // @pyparm string|KLID||Hex string containing a locale id, eg "00000409" + &flags)) // @pyparm int|Flags|0|Combination of win32con.KLF_* constants + return NULL; + lcid=LoadKeyboardLayout(lcid_str, flags); + if (lcid==NULL) + return PyWin_SetAPIError("LoadKeyboardLayout"); + return PyLong_FromLong((long)lcid); + } + + /* List of functions exported by this module */ // @module win32api|A module, encapsulating the Windows Win32 API. *************** *** 4685,4688 **** --- 4736,4740 ---- {"GetFocus", PyGetFocus, 1}, // @pymeth GetFocus|Retrieves the handle of the keyboard focus window associated with the thread that called the method. {"GetFullPathName", PyGetFullPathName,1}, // @pymeth GetFullPathName|Returns the full path of a (possibly relative) path + {"GetKeyboardLayoutList", PyGetKeyboardLayoutList, 1}, // @pymeth GetKeyboardLayoutList|Returns a sequence of all locale ids in the system {"GetKeyState", PyGetKeyState, 1}, // @pymeth GetKeyState|Retrives the last known key state for a key. {"GetLastError", PyGetLastError, 1}, // @pymeth GetLastError|Retrieves the last error code known by the system. *************** *** 4722,4725 **** --- 4774,4778 ---- {"mouse_event", Pymouse_event, 1}, // @pymeth mouse_event|Simulate a mouse event {"LoadCursor", PyLoadCursor, 1}, // @pymeth LoadCursor|Loads a cursor. + {"LoadKeyboardLayout", PyLoadKeyboardLayout, 1}, // @pymeth LoadKeyboardLayout|Loads a new locale id {"LoadLibrary", PyLoadLibrary,1}, // @pymeth LoadLibrary|Loads the specified DLL, and returns the handle. {"LoadLibraryEx", PyLoadLibraryEx,1}, // @pymeth LoadLibraryEx|Loads the specified DLL, and returns the handle. |
From: Roger U. <ru...@us...> - 2005-10-08 07:37:27
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20934/win32/Demos Added Files: GetSaveFileName.py Log Message: Demo using win32gui.GetOpenFileNameW and GetSaveFileNameW --- NEW FILE: GetSaveFileName.py --- import win32gui, win32con, os filter='Python Scripts\0*.py;*.pyw;*.pys\0Text files\0*.txt\0' customfilter='Other file types\0*.*\0' fname, customfilter, flags=win32gui.GetSaveFileNameW( InitialDir=os.environ['temp'], Flags=win32con.OFN_ALLOWMULTISELECT|win32con.OFN_EXPLORER, File='somefilename', DefExt='py', Title='GetSaveFileNameW', Filter=filter, CustomFilter=customfilter, FilterIndex=1) print 'save file names:', repr(fname) print 'filter used:', repr(customfilter) print 'Flags:', flags for k,v in win32con.__dict__.items(): if k.startswith('OFN_') and flags & v: print '\t'+k fname, customfilter, flags=win32gui.GetOpenFileNameW( InitialDir=os.environ['temp'], Flags=win32con.OFN_ALLOWMULTISELECT|win32con.OFN_EXPLORER, File='somefilename', DefExt='py', Title='GetOpenFileNameW', Filter=filter, CustomFilter=customfilter, FilterIndex=0) print 'open file names:', repr(fname) print 'filter used:', repr(customfilter) print 'Flags:', flags for k,v in win32con.__dict__.items(): if k.startswith('OFN_') and flags & v: print '\t'+k |
From: Roger U. <ru...@us...> - 2005-10-08 07:20:43
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18641/win32/src Modified Files: win32gui.i Log Message: Add GetOpenFileNameW and GetSaveFileNameW Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** win32gui.i 30 Sep 2005 04:12:51 -0000 1.69 --- win32gui.i 8 Oct 2005 07:20:34 -0000 1.70 *************** *** 109,112 **** --- 109,122 ---- PyDict_SetItemString(d, "error", PyWinExc_ApiError); + // hack borrowed from win32security since version of SWIG we use doesn't do keyword arguments + #ifdef WINXPGUI + for (PyMethodDef *pmd = winxpguiMethods; pmd->ml_name; pmd++) + #else + for (PyMethodDef *pmd = win32guiMethods; pmd->ml_name; pmd++) + #endif + if (strcmp(pmd->ml_name, "GetOpenFileNameW")==0 || + strcmp(pmd->ml_name, "GetSaveFileNameW")==0) + pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; + %} *************** *** 3296,3309 **** ); - // |SystemParametersInfo|queries or sets system-wide parameters. This function can also update the user profile while setting a parameter. - /** - BOOLAPI SystemParametersInfo( - UINT uiAction, // @pyparm int|uiAction||system parameter to query or set - UINT uiParam, // @pyparm int|uiParam||depends on action to be taken - PVOID pvParam, // @pyparm int|pvParam||depends on action to be taken - UINT fWinIni // @pyparm int|fWinIni||user profile update flag - ); - **/ - // @pyswig |CreateCaret| BOOLAPI CreateCaret( --- 3306,3309 ---- *************** *** 3673,3674 **** --- 3673,3877 ---- %} + %{ + void PyWinObject_FreeOPENFILENAMEW(OPENFILENAMEW *pofn) + { + if (pofn->lpstrFile!=NULL) + free(pofn->lpstrFile); + if (pofn->lpstrCustomFilter!=NULL) + free(pofn->lpstrCustomFilter); + // these are all defined as CONST in the structure + PyWinObject_FreeWCHAR((WCHAR *)pofn->lpstrFilter); + PyWinObject_FreeWCHAR((WCHAR *)pofn->lpstrInitialDir); + PyWinObject_FreeWCHAR((WCHAR *)pofn->lpstrTitle); + PyWinObject_FreeWCHAR((WCHAR *)pofn->lpstrDefExt); + // lpTemplateName can also be a resource id + if ((pofn->lpTemplateName!=NULL) && !IS_INTRESOURCE(pofn->lpTemplateName)) + PyWinObject_FreeWCHAR((WCHAR *)pofn->lpTemplateName); + ZeroMemory(pofn, sizeof(OPENFILENAMEW)); + } + + BOOL PyParse_OPENFILENAMEW_Args(PyObject *args, PyObject *kwargs, OPENFILENAMEW *pofn) + { + BOOL ret=FALSE; + static char * keywords[]={"hwndOwner", "hInstance", "Filter", "CustomFilter", + "FilterIndex", "File", "MaxFile", "InitialDir", + "Title", "Flags", "DefExt", "TemplateName", NULL}; + PyObject *obFilter=Py_None, *obCustomFilter=Py_None, *obFile=Py_None, *obInitialDir=Py_None, + *obTitle=Py_None, *obDefExt=Py_None, *obTemplateName=Py_None, + *obOwner=Py_None, *obhInstance=Py_None; + WCHAR *initfile=NULL, *customfilter=NULL; + DWORD bufsize, initfilechars, customfilterchars; + long template_id; + ZeroMemory(pofn, sizeof(OPENFILENAMEW)); + // ??? may need to set size to OPENFILENAME_SIZE_VERSION_400 to be compatible with NT + pofn->lStructSize=sizeof(OPENFILENAMEW); + pofn->nMaxFile=1024; // default to large buffer since multiple files can be selected + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOOlOlOOlOO:OPENFILENAME", keywords, + &obOwner, // @pyparm <o PyHANDLE>|hwndOwner|None|Handle to window that owns dialog + &obhInstance, // @pyparm <o PyHANDLE>|hInstance|None|Handle to module that contains dialog template + &obFilter, // @pyparm <o PyUNICODE>|Filter|None|Contains pairs of descriptions and filespecs separated by NULLS, with a final trailing NULL. + // Example: 'Python Scripts\0*.py;*.pyw;*.pys\0Text files\0*.txt\0' + &obCustomFilter, // @pyparm <o PyUNICODE>|CustomFilter|None|Description to be used for filter that user selected or typed, can also contain a filespec as above + &pofn->nFilterIndex, // @pyparm int|FilterIndex|0|Specifies which of the filters is initially selected, use 0 for CustomFilter + &obFile, // @pyparm <o PyUNICODE>|File|None|The file name initially displayed + &pofn->nMaxFile, // @pyparm int|MaxFile|1024|Number of characters to allocate for selected filename, override if large number of files expected + &obInitialDir, // @pyparm <o PyUNICODE>|InitialDir|None|The starting directory + &obTitle, // @pyparm <o PyUNICODE>|Title|None|The title of the dialog box + &pofn->Flags, // @pyparm int|Flags|0|Combination of win32con.OFN_* constants + &obDefExt, // @pyparm <o PyUNICODE>|DefExt|None|The default extension to use + &obTemplateName)) // @pyparm <o PyUNICODE>|TemplateName|None|Name of dialog box template + goto done; + + // CustomFilter will have user-selected (or typed) wildcard pattern appended to it + if (obCustomFilter!=Py_None){ + if (!PyWinObject_AsWCHAR(obCustomFilter, &customfilter, FALSE, &customfilterchars)) + goto done; + pofn->nMaxCustFilter=customfilterchars+256; + bufsize=pofn->nMaxCustFilter*sizeof(WCHAR); + pofn->lpstrCustomFilter=(LPWSTR)malloc(bufsize); + if (pofn->lpstrCustomFilter==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d bytes for CustomFilter", bufsize); + goto done; + } + ZeroMemory(pofn->lpstrCustomFilter, bufsize); + memcpy(pofn->lpstrCustomFilter, customfilter, customfilterchars*sizeof(WCHAR)); + } + + // lpstrFile buffer receives full path and possibly multiple file names, allocate extra space + if (!PyWinObject_AsWCHAR(obFile, &initfile, TRUE, &initfilechars)) + goto done; + pofn->nMaxFile=max(pofn->nMaxFile, initfilechars+1); + bufsize=pofn->nMaxFile*sizeof(WCHAR); + pofn->lpstrFile=(LPWSTR)malloc(bufsize); + if (pofn->lpstrFile==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d bytes for File buffer", bufsize); + goto done; + } + ZeroMemory(pofn->lpstrFile, bufsize); + if (initfile!=NULL) + memcpy(pofn->lpstrFile, initfile, initfilechars*sizeof(WCHAR)); + + // lpTemplateName can be a string or a numeric resource id + if (obTemplateName!=Py_None) + if (PyInt_Check(obTemplateName) || PyLong_Check(obTemplateName)){ + template_id=PyInt_AsLong(obTemplateName); + if (template_id==-1 && PyErr_Occurred()) + goto done; + if (!IS_INTRESOURCE(template_id)){ + PyErr_Format(PyExc_ValueError, "%d is not a valid Resource Id", template_id); + goto done; + } + pofn->lpTemplateName=MAKEINTRESOURCEW(template_id); + } + else + if (!PyWinObject_AsWCHAR(obTemplateName, (WCHAR **)&pofn->lpTemplateName)) + goto done; + + ret=PyWinObject_AsHANDLE(obOwner, (PHANDLE)&pofn->hwndOwner, TRUE) && + PyWinObject_AsHANDLE(obhInstance, (PHANDLE)&pofn->hInstance, TRUE) && + PyWinObject_AsWCHAR(obFilter, (WCHAR **)&pofn->lpstrFilter, TRUE) && + PyWinObject_AsWCHAR(obInitialDir, (WCHAR **)&pofn->lpstrInitialDir, TRUE) && + PyWinObject_AsWCHAR(obTitle, (WCHAR **)&pofn->lpstrTitle, TRUE) && + PyWinObject_AsWCHAR(obDefExt, (WCHAR **)&pofn->lpstrDefExt, TRUE); + + done: + if (!ret) + PyWinObject_FreeOPENFILENAMEW(pofn); + PyWinObject_FreeWCHAR(initfile); + PyWinObject_FreeWCHAR(customfilter); + return ret; + } + + PyObject *PyReturn_OPENFILENAMEW_Output(OPENFILENAMEW *pofn) + { + DWORD filechars, filterchars; + // there is no returned length, and lpstrFile can contain NULL's if multiple files are selected + // Walk the string backwards until a non-NULL is found + for (filechars=pofn->nMaxFile; filechars>0; filechars--) + if (pofn->lpstrFile[filechars-1]!=0) + break; + + if (pofn->lpstrCustomFilter==NULL) + return Py_BuildValue("NOk", + PyWinObject_FromWCHAR(pofn->lpstrFile, filechars), + Py_None, + pofn->Flags); + // if CustomFilter if present, can contain NULL's also + for (filterchars=pofn->nMaxCustFilter; filterchars>0; filterchars--) + if (pofn->lpstrCustomFilter[filterchars-1]!=0) + break; + return Py_BuildValue("NNk", + PyWinObject_FromWCHAR(pofn->lpstrFile, filechars), + // include trailing NULL so returned value can be passed back in as a filter unmodified + PyWinObject_FromWCHAR(pofn->lpstrCustomFilter, filterchars+1), + pofn->Flags); + } + %} + + + %native (GetSaveFileNameW) pfnPyGetSaveFileNameW; + %native (GetOpenFileNameW) pfnPyGetOpenFileNameW; + + %{ + // @pyswig (<o PyUNICODE>,<o PyUNICODE>,int)|GetSaveFileNameW|Creates a dialog for user to specify location to save a file or files + // @comm Accepts keyword arguments, all arguments optional + // @rdesc Returns a tuple of 3 values (<o PyUNICODE>, <o PyUNICODE>, int):<nl> + // First is the selected file(s). If multiple files are selected, returned string will be the directory followed by files names + // separated by nulls, otherwise it will be the full path.<nl> + // Second is a unicode string containing user-selected filter, will be None if CustomFilter was not specified<nl> + // Third item contains flags pertaining to users input, such as OFN_READONLY and OFN_EXTENSIONDIFFERENT + // @pyparm <o PyHANDLE>|hwndOwner|None|Handle to window that owns dialog + // @pyparm <o PyHANDLE>|hInstance|None|Handle to module that contains dialog template + // @pyparm <o PyUNICODE>|Filter|None|Contains pairs of descriptions and filespecs separated by NULLS, with a final trailing NULL. + // Example: 'Python Scripts\0*.py;*.pyw;*.pys\0Text files\0*.txt\0' + // @pyparm <o PyUNICODE>|CustomFilter|None|Description to be used for filter that user selected or typed, can also contain a filespec as above + // @pyparm int|FilterIndex|0|Specifies which of the filters is initially selected, use 0 for CustomFilter + // @pyparm <o PyUNICODE>|File|None|The file name initially displayed + // @pyparm int|MaxFile|1024|Number of characters to allocate for selected filename(s), override if large number of files expected + // @pyparm <o PyUNICODE>|InitialDir|None|The starting directory + // @pyparm <o PyUNICODE>|Title|None|The title of the dialog box + // @pyparm int|Flags|0|Combination of win32con.OFN_* constants + // @pyparm <o PyUNICODE>|DefExt|None|The default extension to use + // @pyparm <o PyUNICODE>|TemplateName|None|Name of dialog box template + static PyObject *PyGetSaveFileNameW(PyObject *self, PyObject *args, PyObject *kwargs) + { + PyObject *ret=NULL; + OPENFILENAMEW ofn; + + if (!PyParse_OPENFILENAMEW_Args(args, kwargs, &ofn)) + return NULL; + + if (!GetSaveFileNameW(&ofn)) + PyWin_SetAPIError("GetSaveFileNameW", CommDlgExtendedError()); + else + ret=PyReturn_OPENFILENAMEW_Output(&ofn); + + PyWinObject_FreeOPENFILENAMEW(&ofn); + return ret; + } + + // @pyswig (<o PyUNICODE>,<o PyUNICODE>, int)|GetOpenFileNameW|Creates a dialog to allow user to select file(s) to open + // @comm Accepts keyword arguments, all arguments optional + // Input parameters and return values are identical to <om win32gui.GetSaveFileNameW> + static PyObject *PyGetOpenFileNameW(PyObject *self, PyObject *args, PyObject *kwargs) + { + PyObject *ret=NULL; + OPENFILENAMEW ofn; + + if (!PyParse_OPENFILENAMEW_Args(args, kwargs, &ofn)) + return NULL; + + if (!GetOpenFileNameW(&ofn)) + PyWin_SetAPIError("GetOpenFileNameW", CommDlgExtendedError()); + else + ret=PyReturn_OPENFILENAMEW_Output(&ofn); + + PyWinObject_FreeOPENFILENAMEW(&ofn); + return ret; + } + + // Swig 1.2 chokes on functions that takes keywords + PyCFunction pfnPyGetSaveFileNameW=(PyCFunction)PyGetSaveFileNameW; + PyCFunction pfnPyGetOpenFileNameW=(PyCFunction)PyGetOpenFileNameW; + %} |
From: Roger U. <ru...@us...> - 2005-10-07 11:05:57
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16580/win32/Lib Modified Files: winerror.py Log Message: Add common dialog errors from cderr.h Index: winerror.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/winerror.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** winerror.py 6 Oct 2004 01:58:55 -0000 1.3 --- winerror.py 7 Oct 2005 11:05:46 -0000 1.4 *************** *** 1876,1877 **** --- 1876,1916 ---- ERROR_DS_LDAP_SEND_QUEUE_FULL = 8616 ERROR_DS_DRA_OUT_SCHEDULE_WINDOW = 8617 + + # Common dialog box error codes from cderr.h + CDERR_DIALOGFAILURE = 65535 + CDERR_GENERALCODES = 0 + CDERR_STRUCTSIZE = 1 + CDERR_INITIALIZATION = 2 + CDERR_NOTEMPLATE = 3 + CDERR_NOHINSTANCE = 4 + CDERR_LOADSTRFAILURE = 5 + CDERR_FINDRESFAILURE = 6 + CDERR_LOADRESFAILURE = 7 + CDERR_LOCKRESFAILURE = 8 + CDERR_MEMALLOCFAILURE = 9 + CDERR_MEMLOCKFAILURE = 10 + CDERR_NOHOOK = 11 + CDERR_REGISTERMSGFAIL = 12 + PDERR_PRINTERCODES = 4096 + PDERR_SETUPFAILURE = 4097 + PDERR_PARSEFAILURE = 4098 + PDERR_RETDEFFAILURE = 4099 + PDERR_LOADDRVFAILURE = 4100 + PDERR_GETDEVMODEFAIL = 4101 + PDERR_INITFAILURE = 4102 + PDERR_NODEVICES = 4103 + PDERR_NODEFAULTPRN = 4104 + PDERR_DNDMMISMATCH = 4105 + PDERR_CREATEICFAILURE = 4106 + PDERR_PRINTERNOTFOUND = 4107 + PDERR_DEFAULTDIFFERENT = 4108 + CFERR_CHOOSEFONTCODES = 8192 + CFERR_NOFONTS = 8193 + CFERR_MAXLESSTHANMIN = 8194 + FNERR_FILENAMECODES = 12288 + FNERR_SUBCLASSFAILURE = 12289 + FNERR_INVALIDFILENAME = 12290 + FNERR_BUFFERTOOSMALL = 12291 + FRERR_FINDREPLACECODES = 16384 + FRERR_BUFFERLENGTHZERO = 16385 + CCERR_CHOOSECOLORCODES = 20480 |
From: Roger U. <ru...@us...> - 2005-10-07 10:44:15
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11316/win32/Lib Modified Files: win32con.py Log Message: Add newer SPI_* constants Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32con.py 12 Apr 2005 05:06:24 -0000 1.12 --- win32con.py 7 Oct 2005 10:44:07 -0000 1.13 *************** *** 3504,3507 **** --- 3504,3508 ---- # winuser.h line 8594 + # constants used with SystemParametersInfo SPI_GETBEEP = 1 SPI_SETBEEP = 2 *************** *** 3548,3551 **** --- 3549,3568 ---- SPI_GETWORKAREA = 48 SPI_SETPENWINDOWS = 49 + SPI_GETFILTERKEYS = 50 + SPI_SETFILTERKEYS = 51 + SPI_GETTOGGLEKEYS = 52 + SPI_SETTOGGLEKEYS = 53 + SPI_GETMOUSEKEYS = 54 + SPI_SETMOUSEKEYS = 55 + SPI_GETSHOWSOUNDS = 56 + SPI_SETSHOWSOUNDS = 57 + SPI_GETSTICKYKEYS = 58 + SPI_SETSTICKYKEYS = 59 + SPI_GETACCESSTIMEOUT = 60 + SPI_SETACCESSTIMEOUT = 61 + SPI_GETSERIALKEYS = 62 + SPI_SETSERIALKEYS = 63 + SPI_GETSOUNDSENTRY = 64 + SPI_SETSOUNDSENTRY = 65 SPI_GETHIGHCONTRAST = 66 SPI_SETHIGHCONTRAST = 67 *************** *** 3577,3598 **** SPI_SETMOUSETRAILS = 93 SPI_GETMOUSETRAILS = 94 SPI_SETSCREENSAVERRUNNING = 97 SPI_SCREENSAVERRUNNING = SPI_SETSCREENSAVERRUNNING - SPI_GETFILTERKEYS = 50 - SPI_SETFILTERKEYS = 51 - SPI_GETTOGGLEKEYS = 52 - SPI_SETTOGGLEKEYS = 53 - SPI_GETMOUSEKEYS = 54 - SPI_SETMOUSEKEYS = 55 - SPI_GETSHOWSOUNDS = 56 - SPI_SETSHOWSOUNDS = 57 - SPI_GETSTICKYKEYS = 58 - SPI_SETSTICKYKEYS = 59 - SPI_GETACCESSTIMEOUT = 60 - SPI_SETACCESSTIMEOUT = 61 - SPI_GETSERIALKEYS = 62 - SPI_SETSERIALKEYS = 63 - SPI_GETSOUNDSENTRY = 64 - SPI_SETSOUNDSENTRY = 65 SPI_GETMOUSEHOVERWIDTH = 98 SPI_SETMOUSEHOVERWIDTH = 99 --- 3594,3601 ---- SPI_SETMOUSETRAILS = 93 SPI_GETMOUSETRAILS = 94 + SPI_GETSNAPTODEFBUTTON = 95 + SPI_SETSNAPTODEFBUTTON = 96 SPI_SETSCREENSAVERRUNNING = 97 SPI_SCREENSAVERRUNNING = SPI_SETSCREENSAVERRUNNING SPI_GETMOUSEHOVERWIDTH = 98 SPI_SETMOUSEHOVERWIDTH = 99 *************** *** 3603,3606 **** --- 3606,3612 ---- SPI_GETWHEELSCROLLLINES = 104 SPI_SETWHEELSCROLLLINES = 105 + SPI_GETMENUSHOWDELAY = 106 + SPI_SETMENUSHOWDELAY = 107 + SPI_GETSHOWIMEUI = 110 SPI_SETSHOWIMEUI = 111 *************** *** 3608,3611 **** --- 3614,3619 ---- SPI_SETMOUSESPEED = 113 SPI_GETSCREENSAVERRUNNING = 114 + SPI_GETDESKWALLPAPER = 115 + SPI_GETACTIVEWINDOWTRACKING = 4096 SPI_SETACTIVEWINDOWTRACKING = 4097 *************** *** 3618,3621 **** --- 3626,3631 ---- SPI_GETGRADIENTCAPTIONS = 4104 SPI_SETGRADIENTCAPTIONS = 4105 + SPI_GETKEYBOARDCUES = 4106 + SPI_SETKEYBOARDCUES = 4107 SPI_GETMENUUNDERLINES = 4106 SPI_SETMENUUNDERLINES = 4107 *************** *** 3624,3627 **** --- 3634,3663 ---- SPI_GETHOTTRACKING = 4110 SPI_SETHOTTRACKING = 4111 + + SPI_GETMENUFADE = 4114 + SPI_SETMENUFADE = 4115 + SPI_GETSELECTIONFADE = 4116 + SPI_SETSELECTIONFADE = 4117 + SPI_GETTOOLTIPANIMATION = 4118 + SPI_SETTOOLTIPANIMATION = 4119 + SPI_GETTOOLTIPFADE = 4120 + SPI_SETTOOLTIPFADE = 4121 + SPI_GETCURSORSHADOW = 4122 + SPI_SETCURSORSHADOW = 4123 + SPI_GETMOUSESONAR = 4124 + SPI_SETMOUSESONAR = 4125 + SPI_GETMOUSECLICKLOCK = 4126 + SPI_SETMOUSECLICKLOCK = 4127 + SPI_GETMOUSEVANISH = 4128 + SPI_SETMOUSEVANISH = 4129 + SPI_GETFLATMENU = 4130 + SPI_SETFLATMENU = 4131 + SPI_GETDROPSHADOW = 4132 + SPI_SETDROPSHADOW = 4133 + SPI_GETBLOCKSENDINPUTRESETS = 4134 + SPI_SETBLOCKSENDINPUTRESETS = 4135 + SPI_GETUIEFFECTS = 4158 + SPI_SETUIEFFECTS = 4159 + SPI_GETFOREGROUNDLOCKTIMEOUT = 8192 SPI_SETFOREGROUNDLOCKTIMEOUT = 8193 *************** *** 3630,3636 **** --- 3666,3694 ---- SPI_GETFOREGROUNDFLASHCOUNT = 8196 SPI_SETFOREGROUNDFLASHCOUNT = 8197 + SPI_GETCARETWIDTH = 8198 + SPI_SETCARETWIDTH = 8199 + SPI_GETMOUSECLICKLOCKTIME = 8200 + SPI_SETMOUSECLICKLOCKTIME = 8201 + SPI_GETFONTSMOOTHINGTYPE = 8202 + SPI_SETFONTSMOOTHINGTYPE = 8203 + SPI_GETFONTSMOOTHINGCONTRAST = 8204 + SPI_SETFONTSMOOTHINGCONTRAST = 8205 + SPI_GETFOCUSBORDERWIDTH = 8206 + SPI_SETFOCUSBORDERWIDTH = 8207 + SPI_GETFOCUSBORDERHEIGHT = 8208 + SPI_SETFOCUSBORDERHEIGHT = 8209 + SPI_GETFONTSMOOTHINGORIENTATION = 8210 + SPI_SETFONTSMOOTHINGORIENTATION = 8211 + + # fWinIni flags for SystemParametersInfo SPIF_UPDATEINIFILE = 1 SPIF_SENDWININICHANGE = 2 SPIF_SENDCHANGE = SPIF_SENDWININICHANGE + + # used with SystemParametersInfo and SPI_GETFONTSMOOTHINGTYPE/SPI_SETFONTSMOOTHINGTYPE + FE_FONTSMOOTHINGSTANDARD = 1 + FE_FONTSMOOTHINGCLEARTYPE = 2 + FE_FONTSMOOTHINGDOCKING = 32768 + METRICS_USEDEFAULT = -1 ARW_BOTTOMLEFT = 0 |
From: Roger U. <ru...@us...> - 2005-09-30 04:12:59
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6203/win32/src Modified Files: win32gui.i Log Message: Document parameters to callback function used with EnumFontFamilies Add lfFaceName to PyLOGFONT's member list, check size on input Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** win32gui.i 17 Sep 2005 01:58:29 -0000 1.68 --- win32gui.i 30 Sep 2005 04:12:51 -0000 1.69 *************** *** 108,111 **** --- 108,112 ---- PyDict_SetItemString(d, "dllhandle", PyLong_FromVoidPtr(g_dllhandle)); PyDict_SetItemString(d, "error", PyWinExc_ApiError); + %} *************** *** 1023,1026 **** --- 1024,1028 ---- {"lfQuality", T_BYTE, OFF(m_LOGFONT.lfQuality)}, // @prop integer|lfQuality| {"lfPitchAndFamily", T_BYTE, OFF(m_LOGFONT.lfPitchAndFamily)}, // @prop integer|lfPitchAndFamily| + {"lfFaceName", T_LONG, 0}, // @prop string|lfFaceName|Name of the typeface, at most 31 characters {NULL} /* Sentinel */ }; *************** *** 1063,1069 **** PyLOGFONT *pL = (PyLOGFONT *)self; TCHAR *face; ! if (!PyWinObject_AsTCHAR(v, &face)) ! return NULL; _tcsncpy( pL->m_LOGFONT.lfFaceName, face, LF_FACESIZE ); return 0; } --- 1065,1078 ---- PyLOGFONT *pL = (PyLOGFONT *)self; TCHAR *face; ! DWORD facesize; ! if (!PyWinObject_AsTCHAR(v, &face, FALSE, &facesize)) ! return -1; ! if (facesize >= LF_FACESIZE){ // LF_FACESIZE includes the trailing NULL ! PyErr_Format(PyExc_ValueError, "lfFaceName must be less than %d characters", LF_FACESIZE); ! PyWinObject_FreeTCHAR(face); ! return -1; ! } _tcsncpy( pL->m_LOGFONT.lfFaceName, face, LF_FACESIZE ); + PyWinObject_FreeTCHAR(face); return 0; } *************** *** 1110,1117 **** PyObject *obExtra = Py_None; long hdc; ! // @pyparm int|hdc|| ! // @pyparm string/<o PyUnicode>|family|| ! // @pyparm function|proc||The Python function called with each font family. This function is called with 4 arguments. ! // @pyparm object|extra||An extra param passed to the enum procedure. if (!PyArg_ParseTuple(args, "lOO|O", &hdc, &obFamily, &obProc, &obExtra)) return NULL; --- 1119,1132 ---- PyObject *obExtra = Py_None; long hdc; ! // @pyparm int|hdc||Handle to a device context for which to enumerate available fonts ! // @pyparm string/<o PyUnicode>|Family||Family of fonts to enumerate. If none, first member of each font family will be returned. ! // @pyparm function|EnumFontFamProc||The Python function called with each font family. This function is called with 4 arguments. ! // @pyparm object|Param||An arbitrary object to be passed to the callback function ! // @comm The parameters that the callback function will receive are as follows:<nl> ! // <o PyLOGFONT> - contains the font parameters<nl> ! // None - Placeholder for a TEXTMETRIC structure, not supported yet<nl> ! // int - Font type, combination of DEVICE_FONTTYPE, RASTER_FONTTYPE, TRUETYPE_FONTTYPE<nl> ! // object - The Param originally passed in to EnumFontFamilies ! if (!PyArg_ParseTuple(args, "lOO|O", &hdc, &obFamily, &obProc, &obExtra)) return NULL; *************** *** 2315,2320 **** BOOLAPI DestroyWindow(HWND hwnd); ! // @pyswig int|EnableWindow| ! BOOL EnableWindow(HWND hwnd, BOOL bEnable); // @pyswig int|FindWindow|Retrieves a handle to the top-level window whose class name and window name match the specified strings. --- 2330,2338 ---- BOOLAPI DestroyWindow(HWND hwnd); ! // @pyswig int|EnableWindow|Enables and disables keyboard and mouse input to a window ! // @rdesc Returns True if window was already disabled when call was made, False otherwise ! BOOL EnableWindow( ! HWND hwnd, // @pyparm <o PyHANDLE>|hWnd||Handle to window ! BOOL bEnable); // @pyparm boolean|bEnable||True to enable input to the window, False to disable input // @pyswig int|FindWindow|Retrieves a handle to the top-level window whose class name and window name match the specified strings. *************** *** 3654,3655 **** --- 3672,3674 ---- } %} + |
From: Roger U. <ru...@us...> - 2005-09-30 01:46:50
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13976/win32/src Modified Files: win32consolemodule.cpp Log Message: autoduck fix Index: win32consolemodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32consolemodule.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** win32consolemodule.cpp 28 Sep 2005 02:19:06 -0000 1.6 --- win32consolemodule.cpp 30 Sep 2005 01:46:42 -0000 1.7 *************** *** 890,894 **** {"PeekConsoleInput", (PyCFunction)PyConsoleScreenBuffer::PyPeekConsoleInput, METH_VARARGS|METH_KEYWORDS, "Returns pending input records without removing them from the input queue"}, ! // @pymethod GetNumberOfConsoleInputEvents|Returns the number of unread records in the input queue {"GetNumberOfConsoleInputEvents", PyConsoleScreenBuffer::PyGetNumberOfConsoleInputEvents, METH_VARARGS, "Returns the number of unread records in the input queue"}, --- 890,894 ---- {"PeekConsoleInput", (PyCFunction)PyConsoleScreenBuffer::PyPeekConsoleInput, METH_VARARGS|METH_KEYWORDS, "Returns pending input records without removing them from the input queue"}, ! // @pymeth GetNumberOfConsoleInputEvents|Returns the number of unread records in the input queue {"GetNumberOfConsoleInputEvents", PyConsoleScreenBuffer::PyGetNumberOfConsoleInputEvents, METH_VARARGS, "Returns the number of unread records in the input queue"}, |
From: Roger U. <ru...@us...> - 2005-09-28 02:19:14
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30330/win32/src Modified Files: win32consolemodule.cpp Log Message: Add GetNumberOfConsoleInputEvents Index: win32consolemodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32consolemodule.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32consolemodule.cpp 20 Sep 2005 05:24:46 -0000 1.5 --- win32consolemodule.cpp 28 Sep 2005 02:19:06 -0000 1.6 *************** *** 795,798 **** --- 795,799 ---- static PyObject *PyReadConsoleInput(PyObject *self, PyObject *args, PyObject *kwargs); static PyObject *PyPeekConsoleInput(PyObject *self, PyObject *args, PyObject *kwargs); + static PyObject *PyGetNumberOfConsoleInputEvents(PyObject *self, PyObject *args); }; *************** *** 888,892 **** // @pymeth PeekConsoleInput|Returns pending input records without removing them from the input queue {"PeekConsoleInput", (PyCFunction)PyConsoleScreenBuffer::PyPeekConsoleInput, METH_VARARGS|METH_KEYWORDS, ! "Returns pending input records without removing them from the input queue"}, {NULL} }; --- 889,896 ---- // @pymeth PeekConsoleInput|Returns pending input records without removing them from the input queue {"PeekConsoleInput", (PyCFunction)PyConsoleScreenBuffer::PyPeekConsoleInput, METH_VARARGS|METH_KEYWORDS, ! "Returns pending input records without removing them from the input queue"}, ! // @pymethod GetNumberOfConsoleInputEvents|Returns the number of unread records in the input queue ! {"GetNumberOfConsoleInputEvents", PyConsoleScreenBuffer::PyGetNumberOfConsoleInputEvents, METH_VARARGS, ! "Returns the number of unread records in the input queue"}, {NULL} }; *************** *** 1500,1503 **** --- 1504,1518 ---- } + // @pymethod int|PyConsoleScreenBuffer|GetNumberOfConsoleInputEvents|Returns the number of unread records in the input queue + PyObject *PyConsoleScreenBuffer::PyGetNumberOfConsoleInputEvents(PyObject *self, PyObject *args) + { + if (!PyArg_ParseTuple(args, ":GetNumberOfConsoleInputEvents")) + return NULL; + DWORD nbrofevents; + if (!GetNumberOfConsoleInputEvents(((PyConsoleScreenBuffer *)self)->m_handle, &nbrofevents)) + return PyWin_SetAPIError("GetNumberOfConsoleInputEvents"); + return PyLong_FromUnsignedLong(nbrofevents); + } + |
From: Mark H. <mha...@us...> - 2005-09-27 01:46:42
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25137 Added Files: walk_shell_folders.py Log Message: A little sample showing how to walk IShellFolder interfaces. --- NEW FILE: walk_shell_folders.py --- # A little sample that walks from the desktop into child # items. from win32com.shell import shell, shellcon def walk(folder, depth=2, indent=""): try: pidls = folder.EnumObjects(0, shellcon.SHCONTF_FOLDERS) except shell.error: # no items return for pidl in pidls: dn = folder.GetDisplayNameOf(pidl, shellcon.SHGDN_NORMAL) print indent, dn if depth: try: child = folder.BindToObject(pidl, None, shell.IID_IShellFolder) except shell.error: pass else: walk(child, depth-1, indent+" ") walk(shell.SHGetDesktopFolder()) |
From: Roger U. <ru...@us...> - 2005-09-22 02:22:20
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20254/win32/Demos Added Files: win32console_demo.py Log Message: Demonstrate creating and writing to a screen buffer, and catching keyboard and mouse input --- NEW FILE: win32console_demo.py --- import win32console, win32con import traceback, time virtual_keys={} for k,v in win32con.__dict__.items(): if k.startswith('VK_'): virtual_keys[v]=k free_console=True try: win32console.AllocConsole() except win32console.error, err_tuple: if err_tuple[0]!=5: raise ## only free console if one was created successfully free_console=False stdout=win32console.GetStdHandle(win32console.STD_OUTPUT_HANDLE) stdin=win32console.GetStdHandle(win32console.STD_INPUT_HANDLE) newbuffer=win32console.CreateConsoleScreenBuffer() newbuffer.SetConsoleActiveScreenBuffer() newbuffer.SetConsoleTextAttribute(win32console.FOREGROUND_RED|win32console.FOREGROUND_INTENSITY |win32console.BACKGROUND_GREEN|win32console.BACKGROUND_INTENSITY) newbuffer.WriteConsole('This is a new screen buffer\n') ## test setting screen buffer and window size ## screen buffer size cannot be smaller than window size window_size=newbuffer.GetConsoleScreenBufferInfo()['Window'] coord=win32console.PyCOORDType(X=window_size.Right+20, Y=window_size.Bottom+20) newbuffer.SetConsoleScreenBufferSize(coord) window_size.Right+=10 window_size.Bottom+=10 newbuffer.SetConsoleWindowInfo(Absolute=True,ConsoleWindow=window_size) ## write some records to the input queue x=win32console.PyINPUT_RECORDType(win32console.KEY_EVENT) x.Char=u'X' x.KeyDown=True x.RepeatCount=1 x.VirtualKeyCode=0x58 x.ControlKeyState=win32con.SHIFT_PRESSED z=win32console.PyINPUT_RECORDType(win32console.KEY_EVENT) z.Char=u'Z' z.KeyDown=True z.RepeatCount=1 z.VirtualKeyCode=0x5a z.ControlKeyState=win32con.SHIFT_PRESSED stdin.WriteConsoleInput([x,z,x]) newbuffer.SetConsoleTextAttribute(win32console.FOREGROUND_RED|win32console.FOREGROUND_INTENSITY |win32console.BACKGROUND_GREEN|win32console.BACKGROUND_INTENSITY) newbuffer.WriteConsole('Press some keys, click some characters with the mouse\n') newbuffer.SetConsoleTextAttribute(win32console.FOREGROUND_BLUE|win32console.FOREGROUND_INTENSITY |win32console.BACKGROUND_RED|win32console.BACKGROUND_INTENSITY) newbuffer.WriteConsole('Hit "End" key to quit\n') breakout=False while not breakout: input_records=stdin.ReadConsoleInput(10) for input_record in input_records: if input_record.EventType==win32console.KEY_EVENT: if input_record.KeyDown: if input_record.Char=='\0': newbuffer.WriteConsole(virtual_keys.get(input_record.VirtualKeyCode, 'VirtualKeyCode: %s' %input_record.VirtualKeyCode)) else: newbuffer.WriteConsole(input_record.Char) if input_record.VirtualKeyCode==win32con.VK_END: breakout=True break elif input_record.EventType==win32console.MOUSE_EVENT: if input_record.EventFlags==0: ## 0 indicates a button event if input_record.ButtonState!=0: ## exclude button releases pos=input_record.MousePosition # switch the foreground and background colors of the character that was clicked attr=newbuffer.ReadConsoleOutputAttribute(Length=1, ReadCoord=pos)[0] new_attr=attr if attr&win32console.FOREGROUND_BLUE: new_attr=(new_attr&~win32console.FOREGROUND_BLUE)|win32console.BACKGROUND_BLUE if attr&win32console.FOREGROUND_RED: new_attr=(new_attr&~win32console.FOREGROUND_RED)|win32console.BACKGROUND_RED if attr&win32console.FOREGROUND_GREEN: new_attr=(new_attr&~win32console.FOREGROUND_GREEN)|win32console.BACKGROUND_GREEN if attr&win32console.BACKGROUND_BLUE: new_attr=(new_attr&~win32console.BACKGROUND_BLUE)|win32console.FOREGROUND_BLUE if attr&win32console.BACKGROUND_RED: new_attr=(new_attr&~win32console.BACKGROUND_RED)|win32console.FOREGROUND_RED if attr&win32console.BACKGROUND_GREEN: new_attr=(new_attr&~win32console.BACKGROUND_GREEN)|win32console.FOREGROUND_GREEN newbuffer.WriteConsoleOutputAttribute((new_attr,),pos) else: newbuffer.WriteConsole(str(input_record)) time.sleep(0.1) stdout.SetConsoleActiveScreenBuffer() newbuffer.Close() if free_console: win32console.FreeConsole() |