pywin32-checkins Mailing List for Python for Windows Extensions (Page 85)
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...> - 2007-10-17 03:50:24
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26452/com/win32comext/axcontrol/src Modified Files: PyIOleObject.cpp Log Message: autoduck corrections Index: PyIOleObject.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src/PyIOleObject.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIOleObject.cpp 12 Oct 2007 00:36:12 -0000 1.4 --- PyIOleObject.cpp 17 Oct 2007 03:50:24 -0000 1.5 *************** *** 257,267 **** return NULL; // @pyparm int|iVerb||Description for iVerb ! // *** The input argument lpmsg of type "LPMSG" was not processed *** ! // The type 'LPMSG' (lpmsg) is unknown. // @pyparm <o PyIOleClientSite>|pActiveSite||Description for pActiveSite // @pyparm int|lindex||Description for lindex // @pyparm HWND|hwndParent||Description for hwndParent ! // *** The input argument lprcPosRect of type "LPCRECT" was not processed *** ! // The type 'LPCRECT' (lprcPosRect) is unknown. PyObject *obpActiveSite; LONG iVerb; --- 257,265 ---- return NULL; // @pyparm int|iVerb||Description for iVerb ! // @pyparm <o PyMSG>|msg||MSG tuple, a-la win32gui etc. // @pyparm <o PyIOleClientSite>|pActiveSite||Description for pActiveSite // @pyparm int|lindex||Description for lindex // @pyparm HWND|hwndParent||Description for hwndParent ! // @pyparm (int, int, int, int)|rect|| PyObject *obpActiveSite; LONG iVerb; |
From: Mark H. <mha...@us...> - 2007-10-17 03:49:53
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26068/com/win32comext/shell/src Modified Files: PyIShellFolder.cpp Log Message: correct typo in exception message Index: PyIShellFolder.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellFolder.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PyIShellFolder.cpp 3 Jun 2007 14:53:07 -0000 1.16 --- PyIShellFolder.cpp 17 Oct 2007 03:49:55 -0000 1.17 *************** *** 466,470 **** if (!PyTuple_Check(result)) { PyErr_Format(PyExc_TypeError, ! "ParseDisplayName must return a tuple if (int, pidl, attr) - got '%s'", result->ob_type->tp_name); bPythonIsHappy = FALSE; --- 466,470 ---- if (!PyTuple_Check(result)) { PyErr_Format(PyExc_TypeError, ! "ParseDisplayName must return a tuple of (int, pidl, attr) - got '%s'", result->ob_type->tp_name); bPythonIsHappy = FALSE; |
From: Mark H. <mha...@us...> - 2007-10-16 11:34:07
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/internet/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26502 Modified Files: internet.cpp Log Message: Add some urlmon functions to the under-used win32com.internet module Index: internet.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/internet/src/internet.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** internet.cpp 9 Feb 2001 07:35:54 -0000 1.2 --- internet.cpp 16 Oct 2007 11:34:09 -0000 1.3 *************** *** 24,27 **** --- 24,52 ---- #include "PyIInternetBindInfo.h" + // Check a function pointer that is supplied by a specific IE version (ie, + // we require an IE version later than what is installed) + #define CHECK_IE_PFN(fname) if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available with this Internet Explorer version", #fname); + + typedef HRESULT (WINAPI *CoInternetSetFeatureEnabled_func)(INTERNETFEATURELIST FeatureEntry, DWORD dwFlags, BOOL fEnable); + static CoInternetSetFeatureEnabled_func pfnCoInternetSetFeatureEnabled=NULL; + + typedef HRESULT (WINAPI *CoInternetIsFeatureEnabled_func)(INTERNETFEATURELIST FeatureEntry, DWORD dwFlags); + static CoInternetIsFeatureEnabled_func pfnCoInternetIsFeatureEnabled=NULL; + + HMODULE loadmodule(TCHAR *dllname) + { + HMODULE hmodule = GetModuleHandle(dllname); + if (hmodule==NULL) + hmodule = LoadLibrary(dllname); + return hmodule; + } + + FARPROC loadapifunc(char *funcname, HMODULE hmodule) + { + if (hmodule==NULL) + return NULL; + return GetProcAddress(hmodule, funcname); + } + ////////////////////////////////////////////////////////////// *************** *** 125,129 **** --- 150,186 ---- // The methods // + // @pyswig bool|CoInternetIsFeatureEnabled| + // @rdesc Returns true for S_OK, False for other non-error hresults, or + // raises a com_error. + static PyObject *PyCoInternetIsFeatureEnabled(PyObject *self, PyObject *args) + { + CHECK_IE_PFN(CoInternetIsFeatureEnabled); + int featureEntry, flags; + if (!PyArg_ParseTuple(args, "ii", + &featureEntry, // &pyparm int|featureEntry|| + &flags)) // @pyparm int|flags|| + return NULL; + HRESULT hr = (*pfnCoInternetIsFeatureEnabled)((INTERNETFEATURELIST)featureEntry, flags); + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + PyObject *rc = (hr==S_OK) ? Py_True : Py_False; + Py_INCREF(rc); + return rc; + } + static PyObject *PyCoInternetSetFeatureEnabled(PyObject *self, PyObject *args) + { + CHECK_IE_PFN(CoInternetSetFeatureEnabled); + int featureEntry, flags, enable; + if (!PyArg_ParseTuple(args, "iii", + &featureEntry, // &pyparm int|featureEntry|| + &flags, // @pyparm int|flags|| + &enable)) // @pyparm bool|enable|| + return NULL; + HRESULT hr = (*pfnCoInternetSetFeatureEnabled)((INTERNETFEATURELIST)featureEntry, flags, enable); + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + return PyInt_FromLong(hr); + } *************** *** 132,135 **** --- 189,194 ---- static struct PyMethodDef internet_methods[]= { + { "CoInternetIsFeatureEnabled", PyCoInternetIsFeatureEnabled}, + { "CoInternetSetFeatureEnabled", PyCoInternetSetFeatureEnabled}, { NULL, NULL }, }; *************** *** 174,177 **** --- 233,280 ---- PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(PyCom_InterfaceSupportInfo)); + // load up our function pointers for stuff we can't rely on being + // there at runtime + HMODULE urlmon_dll=loadmodule(_T("urlmon.dll")); + pfnCoInternetSetFeatureEnabled=(CoInternetSetFeatureEnabled_func)loadapifunc("CoInternetSetFeatureEnabled", urlmon_dll); + pfnCoInternetIsFeatureEnabled=(CoInternetIsFeatureEnabled_func)loadapifunc("CoInternetIsFeatureEnabled", urlmon_dll); + + ADD_CONSTANT(FEATURE_OBJECT_CACHING); // @const internet|FEATURE_OBJECT_CACHING| + ADD_CONSTANT(FEATURE_ZONE_ELEVATION); // @const internet|FEATURE_ZONE_ELEVATION| + ADD_CONSTANT(FEATURE_MIME_HANDLING); // @const internet|FEATURE_MIME_HANDLING| + ADD_CONSTANT(FEATURE_MIME_SNIFFING); // @const internet|FEATURE_MIME_SNIFFING| + ADD_CONSTANT(FEATURE_WINDOW_RESTRICTIONS); // @const internet|FEATURE_WINDOW_RESTRICTIONS| + ADD_CONSTANT(FEATURE_WEBOC_POPUPMANAGEMENT); // @const internet|FEATURE_WEBOC_POPUPMANAGEMENT| + ADD_CONSTANT(FEATURE_BEHAVIORS); // @const internet|FEATURE_BEHAVIORS| + ADD_CONSTANT(FEATURE_DISABLE_MK_PROTOCOL); // @const internet|FEATURE_DISABLE_MK_PROTOCOL| + ADD_CONSTANT(FEATURE_LOCALMACHINE_LOCKDOWN); // @const internet|FEATURE_LOCALMACHINE_LOCKDOWN| + ADD_CONSTANT(FEATURE_SECURITYBAND); // @const internet|FEATURE_SECURITYBAND| + ADD_CONSTANT(FEATURE_RESTRICT_ACTIVEXINSTALL); // @const internet|FEATURE_RESTRICT_ACTIVEXINSTALL| + ADD_CONSTANT(FEATURE_VALIDATE_NAVIGATE_URL); // @const internet|FEATURE_VALIDATE_NAVIGATE_URL| + ADD_CONSTANT(FEATURE_RESTRICT_FILEDOWNLOAD); // @const internet|FEATURE_RESTRICT_FILEDOWNLOAD| + ADD_CONSTANT(FEATURE_ADDON_MANAGEMENT); // @const internet|FEATURE_ADDON_MANAGEMENT| + ADD_CONSTANT(FEATURE_PROTOCOL_LOCKDOWN); // @const internet|FEATURE_PROTOCOL_LOCKDOWN| + ADD_CONSTANT(FEATURE_HTTP_USERNAME_PASSWORD_DISABLE); // @const internet|FEATURE_HTTP_USERNAME_PASSWORD_DISABLE| + ADD_CONSTANT(FEATURE_SAFE_BINDTOOBJECT); // @const internet|FEATURE_SAFE_BINDTOOBJECT| + ADD_CONSTANT(FEATURE_UNC_SAVEDFILECHECK); // @const internet|FEATURE_UNC_SAVEDFILECHECK| + ADD_CONSTANT(FEATURE_GET_URL_DOM_FILEPATH_UNENCODED); // @const internet|FEATURE_GET_URL_DOM_FILEPATH_UNENCODED| + ADD_CONSTANT(FEATURE_ENTRY_COUNT); // @const internet|FEATURE_ENTRY_COUNT| + + ADD_CONSTANT(SET_FEATURE_ON_THREAD); // @const internet|SET_FEATURE_ON_THREAD| + ADD_CONSTANT(SET_FEATURE_ON_PROCESS ); // @const internet|SET_FEATURE_ON_PROCESS| + ADD_CONSTANT(SET_FEATURE_IN_REGISTRY ); // @const internet|SET_FEATURE_IN_REGISTRY| + ADD_CONSTANT(SET_FEATURE_ON_THREAD_LOCALMACHINE ); // @const internet|SET_FEATURE_ON_THREAD_LOCALMACHINE| + ADD_CONSTANT(SET_FEATURE_ON_THREAD_INTRANET ); // @const internet|SET_FEATURE_ON_THREAD_INTRANET| + ADD_CONSTANT(SET_FEATURE_ON_THREAD_TRUSTED ); // @const internet|SET_FEATURE_ON_THREAD_TRUSTED| + ADD_CONSTANT(SET_FEATURE_ON_THREAD_INTERNET ); // @const internet|SET_FEATURE_ON_THREAD_INTERNET| + ADD_CONSTANT(SET_FEATURE_ON_THREAD_RESTRICTED ); // @const internet|SET_FEATURE_ON_THREAD_RESTRICTED| + ADD_CONSTANT(GET_FEATURE_FROM_THREAD ); // @const internet|GET_FEATURE_FROM_THREAD| + ADD_CONSTANT(GET_FEATURE_FROM_PROCESS ); // @const internet|GET_FEATURE_FROM_PROCESS| + ADD_CONSTANT(GET_FEATURE_FROM_REGISTRY ); // @const internet|GET_FEATURE_FROM_REGISTRY| + ADD_CONSTANT(GET_FEATURE_FROM_THREAD_LOCALMACHINE ); // @const internet|GET_FEATURE_FROM_THREAD_LOCALMACHINE| + ADD_CONSTANT(GET_FEATURE_FROM_THREAD_INTRANET ); // @const internet|GET_FEATURE_FROM_THREAD_INTRANET| + ADD_CONSTANT(GET_FEATURE_FROM_THREAD_TRUSTED ); // @const internet|GET_FEATURE_FROM_THREAD_TRUSTED| + ADD_CONSTANT(GET_FEATURE_FROM_THREAD_INTERNET ); // @const internet|GET_FEATURE_FROM_THREAD_INTERNET| + ADD_CONSTANT(GET_FEATURE_FROM_THREAD_RESTRICTED ); // @const internet|GET_FEATURE_FROM_THREAD_RESTRICTED| + // ADD_CONSTANT(); // @const internet|| } |
From: Mark H. <mha...@us...> - 2007-10-15 05:20:47
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22833 Modified Files: AXControl.cpp Log Message: autoduck Index: AXControl.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src/AXControl.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AXControl.cpp 12 Oct 2007 00:36:12 -0000 1.7 --- AXControl.cpp 15 Oct 2007 05:20:44 -0000 1.8 *************** *** 394,408 **** ADD_CONSTANT(OLECMDF_NINCHED); // @const axcontrol|OLECMDF_NINCHED| ! ADD_CONSTANT(OLEIVERB_PRIMARY); ! ADD_CONSTANT(OLEIVERB_SHOW); ! ADD_CONSTANT(OLEIVERB_OPEN); ! ADD_CONSTANT(OLEIVERB_HIDE); ! ADD_CONSTANT(OLEIVERB_UIACTIVATE); ! ADD_CONSTANT(OLEIVERB_INPLACEACTIVATE); ! ADD_CONSTANT(OLEIVERB_DISCARDUNDOSTATE); ! ADD_CONSTANT(EMBDHLP_INPROC_HANDLER); ! ADD_CONSTANT(EMBDHLP_INPROC_SERVER); ! ADD_CONSTANT(EMBDHLP_CREATENOW); ! ADD_CONSTANT(EMBDHLP_DELAYCREATE); ! ADD_CONSTANT(OLECREATE_LEAVERUNNING); } --- 394,408 ---- ADD_CONSTANT(OLECMDF_NINCHED); // @const axcontrol|OLECMDF_NINCHED| ! ADD_CONSTANT(OLEIVERB_PRIMARY); // @const axcontrol|OLEIVERB_PRIMARY| ! ADD_CONSTANT(OLEIVERB_SHOW); // @const axcontrol|OLEIVERB_SHOW| ! ADD_CONSTANT(OLEIVERB_OPEN); // @const axcontrol|OLEIVERB_OPEN| ! ADD_CONSTANT(OLEIVERB_HIDE); // @const axcontrol|OLEIVERB_HIDE| ! ADD_CONSTANT(OLEIVERB_UIACTIVATE); // @const axcontrol|OLEIVERB_UIACTIVATE| ! ADD_CONSTANT(OLEIVERB_INPLACEACTIVATE); // @const axcontrol|OLEIVERB_INPLACEACTIVATE| ! ADD_CONSTANT(OLEIVERB_DISCARDUNDOSTATE); // @const axcontrol|OLEIVERB_DISCARDUNDOSTATE| ! ADD_CONSTANT(EMBDHLP_INPROC_HANDLER); // @const axcontrol|EMBDHLP_INPROC_HANDLER| ! ADD_CONSTANT(EMBDHLP_INPROC_SERVER); // @const axcontrol|EMBDHLP_INPROC_SERVER| ! ADD_CONSTANT(EMBDHLP_CREATENOW); // @const axcontrol|EMBDHLP_CREATENOW| ! ADD_CONSTANT(EMBDHLP_DELAYCREATE); // @const axcontrol|EMBDHLP_DELAYCREATE| ! ADD_CONSTANT(OLECREATE_LEAVERUNNING); // @const axcontrol|OLECREATE_LEAVERUNNING| } |
From: Mark H. <mha...@us...> - 2007-10-15 05:11:40
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19596 Modified Files: container_ie.py Log Message: Make this sample a little easier to understand by removing unnecessary typelib generation Index: container_ie.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/demos/container_ie.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** container_ie.py 12 Oct 2007 00:36:12 -0000 1.1 --- container_ie.py 15 Oct 2007 05:11:43 -0000 1.2 *************** *** 6,9 **** --- 6,10 ---- from win32com.server.exception import COMException from win32com.server.util import wrap + from win32com.client import Dispatch import pythoncom *************** *** 16,22 **** debugging = False ! # generate the Dispatchable interfaces we use (IWebBrowser2, etc) ! from win32com.client import gencache, Dispatch ! ie_mod = gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}', 0, 1, 1) IOleClientSite_methods = """SaveObject GetMoniker GetContainer ShowObject --- 17,24 ---- debugging = False ! # If you wanted events or better type info, you'd probably do: ! # gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}', 0, 1, 1) ! # which is the "Microsoft Internet Controls" typelib defining interfaces ! # such as IWebBrowser2 and the associated events. IOleClientSite_methods = """SaveObject GetMoniker GetContainer ShowObject *************** *** 186,190 **** rect = win32gui.GetWindowRect(self.hwnd) browser.DoVerb(axcontrol.OLEIVERB_SHOW, None, site, -1, self.hwnd, rect) ! b2 = ie_mod.IWebBrowser2(browser.QueryInterface(pythoncom.IID_IDispatch)) self.browser2 = b2 b2.Left = 0 --- 188,192 ---- rect = win32gui.GetWindowRect(self.hwnd) browser.DoVerb(axcontrol.OLEIVERB_SHOW, None, site, -1, self.hwnd, rect) ! b2 = Dispatch(browser.QueryInterface(pythoncom.IID_IDispatch)) self.browser2 = b2 b2.Left = 0 *************** *** 215,218 **** win32gui.PumpMessages() - - --- 217,218 ---- |
From: Mark H. <mha...@us...> - 2007-10-12 00:36:10
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7708/src Modified Files: AXControl.cpp PyIOleInPlaceSite.cpp PyIOleObject.cpp Log Message: More ActiveX control work, and a demo of an enbedded IE control without resorting to MFC/Pythonwin Index: PyIOleObject.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src/PyIOleObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIOleObject.cpp 4 Jun 2000 05:57:04 -0000 1.3 --- PyIOleObject.cpp 12 Oct 2007 00:36:12 -0000 1.4 *************** *** 269,283 **** LONG lindex; HWND hwndParent; ! MSG msg; ! LPMSG lpmsg = &msg; RECT rect; LPCRECT lprcPosRect = ▭ ! if ( !PyArg_ParseTuple(args, "iOii(iiii):DoVerb", &iVerb, &obpActiveSite, &lindex, &hwndParent, &rect.left, &rect.top, &rect.right, &rect.bottom) ) return NULL; ! //PyObject *arglst = Py_BuildValue("((iiiii(ii)))",msg->hwnd,msg->message,msg->wParam,msg->lParam,msg->time,msg->pt.x,msg->pt.y); ! // TODO Handle Message Structure ! lpmsg = NULL; BOOL bPythonIsHappy = TRUE; --- 269,285 ---- LONG lindex; HWND hwndParent; ! MSG msg, *lpmsg = NULL; ! PyObject *obMsg; RECT rect; LPCRECT lprcPosRect = ▭ ! if ( !PyArg_ParseTuple(args, "iOOii(iiii):DoVerb", &iVerb, &obMsg, &obpActiveSite, &lindex, &hwndParent, &rect.left, &rect.top, &rect.right, &rect.bottom) ) return NULL; ! if (obMsg != Py_None) { ! lpmsg = &msg; ! if (!PyWinObject_AsMSG(obMsg, &msg)) ! return NULL; ! } BOOL bPythonIsHappy = TRUE; Index: AXControl.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src/AXControl.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AXControl.cpp 13 Feb 2006 12:20:40 -0000 1.6 --- AXControl.cpp 12 Oct 2007 00:36:12 -0000 1.7 *************** *** 292,295 **** --- 292,323 ---- } + // @pymethod |axcontrol|OleSetContainedObject|Notifies an object embedded in an OLE container to ensure correct reference. + static PyObject *axcontrol_OleSetContainedObject(PyObject *, PyObject *args) + { + PyObject *ret = NULL; + PyObject *obunk; + int fContained; + if (!PyArg_ParseTuple(args, "Oi", + &obunk, // @pyparm <o PyIUnknown>|unk||The object + &fContained)) // @pyparm int|fContained|| + return NULL; + + IUnknown *punk = NULL; + HRESULT hr; + if (!PyCom_InterfaceFromPyInstanceOrObject(obunk, IID_IUnknown, (void **)&punk, FALSE)) + goto done; + + Py_BEGIN_ALLOW_THREADS + hr = ::OleSetContainedObject(punk, fContained); + Py_END_ALLOW_THREADS + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + ret = Py_None; + Py_INCREF(Py_None); + done: + return ret; + } *************** *** 301,304 **** --- 329,335 ---- { "OleLoadPicture", axcontrol_OleLoadPicture, 1 }, // @pymeth OleLoadPicture|Creates a new picture object and initializes it from the contents of a stream. { "OleLoadPicturePath", axcontrol_OleLoadPicturePath, 1}, // @pymeth OleLoadPicturePath|Creates a new picture object and initializes it from the contents of a stream. + { "OleSetContainedObject", axcontrol_OleSetContainedObject, 1}, // @pymeth OleSetContainedObject|Notifies an object embedded in an OLE container to ensure correct reference. + + { NULL, NULL }, }; *************** *** 363,365 **** --- 394,408 ---- ADD_CONSTANT(OLECMDF_NINCHED); // @const axcontrol|OLECMDF_NINCHED| + ADD_CONSTANT(OLEIVERB_PRIMARY); + ADD_CONSTANT(OLEIVERB_SHOW); + ADD_CONSTANT(OLEIVERB_OPEN); + ADD_CONSTANT(OLEIVERB_HIDE); + ADD_CONSTANT(OLEIVERB_UIACTIVATE); + ADD_CONSTANT(OLEIVERB_INPLACEACTIVATE); + ADD_CONSTANT(OLEIVERB_DISCARDUNDOSTATE); + ADD_CONSTANT(EMBDHLP_INPROC_HANDLER); + ADD_CONSTANT(EMBDHLP_INPROC_SERVER); + ADD_CONSTANT(EMBDHLP_CREATENOW); + ADD_CONSTANT(EMBDHLP_DELAYCREATE); + ADD_CONSTANT(OLECREATE_LEAVERUNNING); } Index: PyIOleInPlaceSite.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src/PyIOleInPlaceSite.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIOleInPlaceSite.cpp 1 Sep 1999 23:05:44 -0000 1.1 --- PyIOleInPlaceSite.cpp 12 Oct 2007 00:36:12 -0000 1.2 *************** *** 312,331 **** if (ppDoc==NULL) return E_POINTER; PyObject *result; ! HRESULT hr=InvokeViaPolicy("GetWindowContext", &result, ""); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params PyObject *obppFrame; PyObject *obppDoc; ! PyObject *obNone; ! if (!PyArg_ParseTuple(result, "OO(llll)(llll)O" , &obppFrame, &obppDoc, &lprcPosRect->left, &lprcPosRect->top, &lprcPosRect->right, &lprcPosRect->bottom, &lprcClipRect->left, &lprcClipRect->top, &lprcClipRect->right, &lprcClipRect->bottom, ! &obNone)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); BOOL bPythonIsHappy = TRUE; if (!PyCom_InterfaceFromPyInstanceOrObject(obppFrame, IID_IOleInPlaceFrame, (void **)ppFrame, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; if (!PyCom_InterfaceFromPyInstanceOrObject(obppDoc, IID_IOleInPlaceUIWindow, (void **)ppDoc, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); --- 312,336 ---- if (ppDoc==NULL) return E_POINTER; PyObject *result; ! HRESULT hr=InvokeViaPolicy("GetWindowContext", &result); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params PyObject *obppFrame; PyObject *obppDoc; ! PyObject *obFrame; ! PyObject *obAccel; ! if (!PyArg_ParseTuple(result, "OO(llll)(llll)(iOOi)" , &obppFrame, &obppDoc, &lprcPosRect->left, &lprcPosRect->top, &lprcPosRect->right, &lprcPosRect->bottom, &lprcClipRect->left, &lprcClipRect->top, &lprcClipRect->right, &lprcClipRect->bottom, ! &lpFrameInfo->fMDIApp, &obFrame, &obAccel, &lpFrameInfo->cAccelEntries)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); BOOL bPythonIsHappy = TRUE; if (!PyCom_InterfaceFromPyInstanceOrObject(obppFrame, IID_IOleInPlaceFrame, (void **)ppFrame, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; if (!PyCom_InterfaceFromPyInstanceOrObject(obppDoc, IID_IOleInPlaceUIWindow, (void **)ppDoc, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (bPythonIsHappy && !PyWinObject_AsHANDLE(obFrame, (HANDLE *)&lpFrameInfo->hwndFrame)) ! bPythonIsHappy = FALSE; ! if (bPythonIsHappy && !PyWinObject_AsHANDLE(obAccel, (HANDLE *)&lpFrameInfo->haccel)) ! bPythonIsHappy = FALSE; if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); *************** *** 377,381 **** { PY_GATEWAY_METHOD; ! HRESULT hr=InvokeViaPolicy("OnPosRectChange", NULL, "(llll)", pr->left, pr->top, pr->right, pr->bottom); return hr; } --- 382,386 ---- { PY_GATEWAY_METHOD; ! HRESULT hr=InvokeViaPolicy("OnPosRectChange", NULL, "((llll))", pr->left, pr->top, pr->right, pr->bottom); return hr; } |
From: Mark H. <mha...@us...> - 2007-10-12 00:36:10
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7708/demos Added Files: container_ie.py Log Message: More ActiveX control work, and a demo of an enbedded IE control without resorting to MFC/Pythonwin --- NEW FILE: container_ie.py --- # An example of hosting an IE app (without using Pythonwin/MFC) # A nod to the Code Project's article "Embed an HTML control in your own # window using plain C" import sys from win32com.axcontrol import axcontrol from win32com.server.exception import COMException from win32com.server.util import wrap import pythoncom import win32con import win32gui import winerror import win32api # Set to True to see debug output in the 'trace collector' window. debugging = False # generate the Dispatchable interfaces we use (IWebBrowser2, etc) from win32com.client import gencache, Dispatch ie_mod = gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}', 0, 1, 1) IOleClientSite_methods = """SaveObject GetMoniker GetContainer ShowObject OnShowWindow RequestNewObjectLayout""".split() IOleInPlaceSite_methods = """GetWindow ContextSensitiveHelp CanInPlaceActivate OnInPlaceActivate OnUIActivate GetWindowContext Scroll OnUIDeactivate OnInPlaceDeactivate DiscardUndoState DeactivateAndUndo OnPosRectChange""".split() IOleInPlaceFrame_methods = """GetWindow ContextSensitiveHelp GetBorder RequestBorderSpace SetBorderSpace SetActiveObject InsertMenus SetMenu RemoveMenus SetStatusText EnableModeless TranslateAccelerator""".split() class SimpleSite: _com_interfaces_ = [axcontrol.IID_IOleClientSite, axcontrol.IID_IOleInPlaceSite] _public_methods_ = IOleClientSite_methods + IOleInPlaceSite_methods def __init__(self, host_window): self.hw = host_window # IID_IOleClientSite methods def SaveObject(self): raise COMException(hresult=winerror.E_NOTIMPL) def GetMoniker(self, dwAssign, which): raise COMException(hresult=winerror.E_NOTIMPL) def GetContainer(self): raise COMException(hresult=winerror.E_NOINTERFACE) def ShowObject(self): pass def OnShowWindow(self, fShow): pass def RequestNewObjectLayout(self): raise COMException(hresult=winerror.E_NOTIMPL) # IID_IOleInPlaceSite methods def GetWindow(self): return self.hw.hwnd def ContextSensitiveHelp(self, fEnter): raise COMException(hresult=winerror.E_NOTIMPL) def CanInPlaceActivate(self): pass # we can def OnInPlaceActivate(self): pass def OnUIActivate(self): pass def GetWindowContext(self): # return IOleInPlaceFrame, IOleInPlaceUIWindow, rect, clip_rect, frame_info # where frame_info is (fMDIApp, hwndFrame, hAccel, nAccel) return self.hw.ole_frame, None, (0,0,0,0), (0,0,0,0), (True, self.hw.hwnd, None, 0) def Scroll(self, size): raise COMException(hresult=winerror.E_NOTIMPL) def OnUIDeactivate(self, fUndoable): pass def OnInPlaceDeactivate(self): pass def DiscardUndoState(self): raise COMException(hresult=winerror.E_NOTIMPL) def DeactivateAndUndo(self): raise COMException(hresult=winerror.E_NOTIMPL) def OnPosRectChange(self, rect): browser_ob = self.hw.browser.QueryInterface(axcontrol.IID_IOleInPlaceObject) browser_ob.SetObjectRects(rect, rect) class SimpleFrame: #_com_interfaces_ = [axcontrol.IID_IOleInPlaceFrame] _public_methods_ = IOleInPlaceFrame_methods def __init__(self, host_window): self.hw = host_window def GetWindow(self): return self.hw.hwnd def ContextSensitiveHelp(self, fEnterMode): raise COMException(hresult=winerror.E_NOTIMPL) def GetBorder(self): raise COMException(hresult=winerror.E_NOTIMPL) def RequestBorderSpace(self, widths): raise COMException(hresult=winerror.E_NOTIMPL) def SetBorderSpace(self, widths): raise COMException(hresult=winerror.E_NOTIMPL) def SetActiveObject(self, ob, name): pass def InsertMenus(self, hmenuShared, menuWidths): raise COMException(hresult=winerror.E_NOTIMPL) def SetMenu(self, hmenuShared, holemenu, hwndActiveObject): pass def RemoveMenus(self, hmenuShared): pass def SetStatusText(self, statusText): pass def EnableModeless(self, fEnable): pass def TranslateAccelerator(self, msg, wID): raise COMException(hresult=winerror.E_NOTIMPL) # A class that manages the top-level window. class IEHost: wnd_class_name = 'EmbeddedBrowser' def __init__(self): self.hwnd = None self.ole_frame = None def __del__(self): try: win32gui.UnregisterClass(self.wnd_class_name, None) except win32gui.error: pass def create_window(self): message_map = { win32con.WM_SIZE: self.OnSize, win32con.WM_DESTROY: self.OnDestroy, } wc = win32gui.WNDCLASS() wc.lpszClassName = self.wnd_class_name #wc.style = win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW #wc.hbrBackground = win32con.COLOR_WINDOW+1 wc.lpfnWndProc = message_map class_atom=win32gui.RegisterClass(wc) self.hwnd = win32gui.CreateWindow(wc.lpszClassName, 'Embedded browser', win32con.WS_OVERLAPPEDWINDOW | win32con.WS_VISIBLE, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, 0, 0, 0, None) browser = pythoncom.CoCreateInstance("{8856F961-340A-11D0-A96B-00C04FD705A2}", None, pythoncom.CLSCTX_INPROC_SERVER | pythoncom.CLSCTX_INPROC_HANDLER, axcontrol.IID_IOleObject) self.browser = browser site = wrap(SimpleSite(self), axcontrol.IID_IOleClientSite, useDispatcher=debugging) browser.SetClientSite(site) browser.SetHostNames("IE demo", "Hi there") axcontrol.OleSetContainedObject(self.browser, True) rect = win32gui.GetWindowRect(self.hwnd) browser.DoVerb(axcontrol.OLEIVERB_SHOW, None, site, -1, self.hwnd, rect) b2 = ie_mod.IWebBrowser2(browser.QueryInterface(pythoncom.IID_IDispatch)) self.browser2 = b2 b2.Left = 0 b2.Top = 0 b2.Width = rect[2] b2.Height = rect[3] def OnSize(self, hwnd, msg, wparam, lparam): self.browser2.Width = win32api.LOWORD(lparam) self.browser2.Height = win32api.HIWORD(lparam) def OnDestroy(self, hwnd, msg, wparam, lparam): self.browser.Close(axcontrol.OLECLOSE_NOSAVE) self.browser = None self.browser2 = None win32gui.PostQuitMessage(0) if __name__=='__main__': h = IEHost() h.create_window() if len(sys.argv) < 2: h.browser2.Navigate2("about:blank") doc = h.browser2.Document doc.write('This is an IE page hosted by <a href="http://www.python.org">python</a>') doc.write('<br>(you can also specify a URL on the command-line...)') else: h.browser2.Navigate2(sys.argv[1]) win32gui.PumpMessages() |
From: Mark H. <mha...@us...> - 2007-10-12 00:35:18
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7340 Modified Files: PyWinTypes.h PyWinTypesmodule.cpp win32gui.i Log Message: Add utility functions for handling MSG structures. Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** PyWinTypesmodule.cpp 12 Aug 2007 08:10:28 -0000 1.33 --- PyWinTypesmodule.cpp 12 Oct 2007 00:35:09 -0000 1.34 *************** *** 743,746 **** --- 743,775 ---- } + BOOL PyWinObject_AsMSG(PyObject *ob, MSG *pMsg) + { + PyObject *obhwnd; + if (!PyArg_ParseTuple(ob, "Oiiii(ii):MSG param", + &obhwnd, + &pMsg->message, + &pMsg->wParam, + &pMsg->lParam, + &pMsg->time, + &pMsg->pt.x, + &pMsg->pt.y)) + return FALSE; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&pMsg->hwnd)) + return FALSE; + return TRUE; + } + + PyObject *PyWinObject_FromMSG(MSG *pMsg) + { + return Py_BuildValue("Niiii(ii)", + PyWinLong_FromHANDLE(pMsg->hwnd), + pMsg->message, + pMsg->wParam, + pMsg->lParam, + pMsg->time, + pMsg->pt.x, + pMsg->pt.y); + } + /* List of functions exported by this module */ Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** PyWinTypes.h 12 Aug 2007 08:10:28 -0000 1.48 --- PyWinTypes.h 12 Oct 2007 00:35:09 -0000 1.49 *************** *** 534,537 **** --- 534,541 ---- PYWINTYPES_EXPORT BOOL PyWinObject_CloseHKEY(PyObject *obHandle); + // MSG structure keeps coming up... + PYWINTYPES_EXPORT BOOL PyWinObject_AsMSG(PyObject *ob, MSG *pMsg); + PYWINTYPES_EXPORT PyObject *PyWinObject_FromMSG(const MSG *pMsg); + #include "winsock.h" /* Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** win32gui.i 3 Sep 2007 05:01:59 -0000 1.111 --- win32gui.i 12 Oct 2007 00:35:09 -0000 1.112 *************** *** 347,359 **** %typemap(python,argout) MSG *OUTPUT{ ! PyObject *o; ! o = Py_BuildValue("Niiii(ii)", ! PyWinLong_FromHANDLE($source->hwnd), ! $source->message, ! $source->wParam, ! $source->lParam, ! $source->time, ! $source->pt.x, ! $source->pt.y); if (!$target) { $target = o; --- 347,351 ---- %typemap(python,argout) MSG *OUTPUT{ ! PyObject *o = PyWinObject_FromMSG($source); if (!$target) { $target = o; *************** *** 374,390 **** %typemap(python,in) MSG *INPUT { - PyObject *obhwnd; $target = (MSG *)_alloca(sizeof(MSG)); ! if (!PyArg_ParseTuple($source, "Oiiii(ii):MSG param for $name", ! &obhwnd, ! &$target->message, ! &$target->wParam, ! &$target->lParam, ! &$target->time, ! &$target->pt.x, ! &$target->pt.y)) return NULL; - if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&$target->hwnd)) - return NULL; } %typemap(python,ignore) RECT *OUTPUT(RECT rect_output) --- 366,372 ---- %typemap(python,in) MSG *INPUT { $target = (MSG *)_alloca(sizeof(MSG)); ! if (!PyWinObject_AsMSG($source, $target)) return NULL; } %typemap(python,ignore) RECT *OUTPUT(RECT rect_output) |
From: Mark H. <mha...@us...> - 2007-10-12 00:33:12
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6939/demos Log Message: Directory /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/demos added to the repository |
From: Mark H. <mha...@us...> - 2007-09-11 08:55:19
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17475 Modified Files: oleargs.cpp Log Message: * Prevent PyCom_MakeOlePythonCall(), which is called by pythonwin's OCX support from doing evil things if a result tuple is too small. * When a byref bool is required, return either VARIANT_TRUE (-1) or VARIANT_FALSE (0), not simply the integer value (which would be 1 if True was passed) Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** oleargs.cpp 27 Aug 2007 08:38:43 -0000 1.39 --- oleargs.cpp 11 Sep 2007 08:55:20 -0000 1.40 *************** *** 1222,1226 **** if (!VALID_BYREF_MISSING(obj)) { if ((obUse=PyNumber_Int(obj))==NULL) BREAK_FALSE ! *MYBOOLREF = (VARIANT_BOOL)PyInt_AsLong(obj); } else *MYBOOLREF = 0; --- 1222,1226 ---- if (!VALID_BYREF_MISSING(obj)) { if ((obUse=PyNumber_Int(obj))==NULL) BREAK_FALSE ! *MYBOOLREF = PyInt_AsLong(obj) ? VARIANT_TRUE : VARIANT_FALSE; } else *MYBOOLREF = 0; *************** *** 1414,1424 **** // make the return type PyObject *simpleRet; ! if (PyTuple_Check(result)) { simpleRet = PyTuple_GetItem(result, 0); int retNumber = 1; ! int retTotal = PyTuple_Size(result)-1; // Params are reverse order - loop from the back. ! for (unsigned int param=params->cArgs;param!=0;param--) { if (pHelpers[param-1].m_bIsOut) { PyObject *val = PyTuple_GetItem(result, retNumber); --- 1414,1424 ---- // make the return type PyObject *simpleRet; ! if (PyTuple_Check(result) && PyTuple_Size(result)) { simpleRet = PyTuple_GetItem(result, 0); int retNumber = 1; ! int retTotal = PyTuple_Size(result); // Params are reverse order - loop from the back. ! for (unsigned int param=params->cArgs;param!=0 && retNumber < retTotal;param--) { if (pHelpers[param-1].m_bIsOut) { PyObject *val = PyTuple_GetItem(result, retNumber); |
From: Roger U. <ru...@us...> - 2007-09-09 05:35:50
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13876 Modified Files: CHANGES.txt Log Message: Add a few more recent changes Index: CHANGES.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/CHANGES.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CHANGES.txt 28 Jun 2007 18:00:13 -0000 1.9 --- CHANGES.txt 9 Sep 2007 05:35:50 -0000 1.10 *************** *** 14,21 **** --- 14,23 ---- ReadClassStm/WriteClassStm CreateStreamOnHGlobal + CreateILockBytesOnHGlobal * win32com.shell: PyIExtractImage PyIEmptyVolumecache + IsUserAnAdmin * win32transaction: New module containing Kernel Transaction Manager (KTM) functions *************** *** 60,63 **** --- 62,66 ---- (fixes bug #1267366) Add DrawTextW (feature request #1173716) + PtInRect * win32process: *************** *** 65,68 **** --- 68,72 ---- GetGuiResources GetProcessId + IsWow64Process * win32print: *************** *** 72,75 **** --- 76,82 ---- * win32security: Added DuplicateTokenEx + GetTokenInformation and SetTokenInformation support new Vista information classes + Add IsTokenRestricted + Add LogonUserEx * mmapfile: *************** *** 79,82 **** --- 86,96 ---- Document use in help file, and a demo script + * win32pipe: + GetNamedPipeClientProcessId + GetNamedPipeServerProcessId + GetNamedPipeClientSessionId + GetNamedPipeServerSessionId + GetNamedPipeInfo + Build 210 - Sept. 23 2006 ------------------------- |
From: Roger U. <ru...@us...> - 2007-09-09 05:32:53
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12823/win32/src Modified Files: win32pipe.i Log Message: Add GetNamedPipeClientSessionId, GetNamedPipeServerSessionId, and GetNamedPipeInfo Index: win32pipe.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32pipe.i,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** win32pipe.i 9 Sep 2007 01:38:09 -0000 1.16 --- win32pipe.i 9 Sep 2007 05:32:54 -0000 1.17 *************** *** 18,21 **** --- 18,24 ---- static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeClientProcessId = NULL; static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeServerProcessId = NULL; + static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeClientSessionId = NULL; + static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeServerSessionId = NULL; + // Global used to determine if Win9x win32pipe hack is necessary. *************** *** 123,126 **** --- 126,131 ---- pfnGetNamedPipeClientProcessId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeClientProcessId"); pfnGetNamedPipeServerProcessId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeServerProcessId"); + pfnGetNamedPipeClientSessionId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeClientSessionId"); + pfnGetNamedPipeServerSessionId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeServerSessionId"); } %} *************** *** 431,435 **** // @flag NMPWAIT_USE_DEFAULT_WAIT|The time-out interval is the default value specified by the server process in the CreateNamedPipe function. // @flag NMPWAIT_WAIT_FOREVER|The function does not return until an instance of the named pipe is available ! %{ --- 436,448 ---- // @flag NMPWAIT_USE_DEFAULT_WAIT|The time-out interval is the default value specified by the server process in the CreateNamedPipe function. // @flag NMPWAIT_WAIT_FOREVER|The function does not return until an instance of the named pipe is available ! ! // @pyswig (int, int, int, int)|GetNamedPipeInfo|Returns pipe's flags, buffer sizes, and max instances ! BOOLAPI GetNamedPipeInfo( ! HANDLE hNamedPipe, // @pyparm <o PyHANDLE>|hNamedPipe||Handle to a named pipe ! DWORD *OUTPUT, ! DWORD *OUTPUT, ! DWORD *OUTPUT, ! DWORD *OUTPUT); ! %{ *************** *** 504,509 **** return PyLong_FromUnsignedLong(pid); } %} %native(GetNamedPipeClientProcessId) MyGetNamedPipeClientProcessId; %native(GetNamedPipeServerProcessId) MyGetNamedPipeServerProcessId; ! --- 517,559 ---- return PyLong_FromUnsignedLong(pid); } + + // @pyswig int|GetNamedPipeClientSessionId|Returns the session id of client that is connected to a named pipe + // @comm Requires Vista or later + PyObject *MyGetNamedPipeClientSessionId(PyObject *self, PyObject *args) + { + CHECK_PFN(GetNamedPipeClientSessionId); + HANDLE hNamedPipe; + DWORD pid; + PyObject *obhNamedPipe; + // @pyparm <o PyHANDLE>|hPipe||The handle to the pipe. + if (!PyArg_ParseTuple(args, "O:GetNamedPipeClientSessionId", &obhNamedPipe)) + return NULL; + if (!PyWinObject_AsHANDLE(obhNamedPipe, &hNamedPipe)) + return NULL; + if (!(*pfnGetNamedPipeClientSessionId)(hNamedPipe, &pid)) + return PyWin_SetAPIError("GetNamedPipeClientSessionId"); + return PyLong_FromUnsignedLong(pid); + } + + // @pyswig int|GetNamedPipeServerSessionId|Returns session id of server process that created a named pipe + // @comm Requires Vista or later + PyObject *MyGetNamedPipeServerSessionId(PyObject *self, PyObject *args) + { + CHECK_PFN(GetNamedPipeServerSessionId); + HANDLE hNamedPipe; + DWORD pid; + PyObject *obhNamedPipe; + // @pyparm <o PyHANDLE>|hPipe||The handle to the pipe. + if (!PyArg_ParseTuple(args, "O:GetNamedPipeServerSessionId", &obhNamedPipe)) + return NULL; + if (!PyWinObject_AsHANDLE(obhNamedPipe, &hNamedPipe)) + return NULL; + if (!(*pfnGetNamedPipeServerSessionId)(hNamedPipe, &pid)) + return PyWin_SetAPIError("GetNamedPipeServerSessionId"); + return PyLong_FromUnsignedLong(pid); + } %} %native(GetNamedPipeClientProcessId) MyGetNamedPipeClientProcessId; %native(GetNamedPipeServerProcessId) MyGetNamedPipeServerProcessId; ! %native(GetNamedPipeClientSessionId) MyGetNamedPipeClientSessionId; ! %native(GetNamedPipeServerSessionId) MyGetNamedPipeServerSessionId; |
From: Roger U. <ru...@us...> - 2007-09-09 01:38:07
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26532/win32/src Modified Files: win32pipe.i Log Message: Add GetNamedPipeClientProcessId and GetNamedPipeServerProcessId Index: win32pipe.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32pipe.i,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32pipe.i 6 Jun 2007 21:41:46 -0000 1.15 --- win32pipe.i 9 Sep 2007 01:38:09 -0000 1.16 *************** *** 14,17 **** --- 14,21 ---- %{ + #define CHECK_PFN(fname)if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); + typedef BOOL (WINAPI *GetNamedPipeClientProcessIdfunc)(HANDLE, PULONG); + static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeClientProcessId = NULL; + static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeServerProcessId = NULL; // Global used to determine if Win9x win32pipe hack is necessary. *************** *** 113,116 **** --- 117,127 ---- } } + HMODULE hmod=GetModuleHandle("Kernel32.dll"); + if (!hmod) + hmod=LoadLibrary("Kernel32.dll"); + if (hmod){ + pfnGetNamedPipeClientProcessId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeClientProcessId"); + pfnGetNamedPipeServerProcessId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeServerProcessId"); + } %} *************** *** 456,457 **** --- 467,509 ---- %native(PeekNamedPipe) MyPeekNamedPipe; + + %{ + // @pyswig int|GetNamedPipeClientProcessId|Returns the process id of client that is connected to a named pipe + // @comm Requires Vista or later + PyObject *MyGetNamedPipeClientProcessId(PyObject *self, PyObject *args) + { + CHECK_PFN(GetNamedPipeClientProcessId); + HANDLE hNamedPipe; + DWORD pid; + PyObject *obhNamedPipe; + // @pyparm <o PyHANDLE>|hPipe||The handle to the pipe. + if (!PyArg_ParseTuple(args, "O:GetNamedPipeClientProcessId", &obhNamedPipe)) + return NULL; + if (!PyWinObject_AsHANDLE(obhNamedPipe, &hNamedPipe)) + return NULL; + if (!(*pfnGetNamedPipeClientProcessId)(hNamedPipe, &pid)) + return PyWin_SetAPIError("GetNamedPipeClientProcessId"); + return PyLong_FromUnsignedLong(pid); + } + + // @pyswig int|GetNamedPipeServerProcessId|Returns pid of server process that created a named pipe + // @comm Requires Vista or later + PyObject *MyGetNamedPipeServerProcessId(PyObject *self, PyObject *args) + { + CHECK_PFN(GetNamedPipeServerProcessId); + HANDLE hNamedPipe; + DWORD pid; + PyObject *obhNamedPipe; + // @pyparm <o PyHANDLE>|hPipe||The handle to the pipe. + if (!PyArg_ParseTuple(args, "O:GetNamedPipeServerProcessId", &obhNamedPipe)) + return NULL; + if (!PyWinObject_AsHANDLE(obhNamedPipe, &hNamedPipe)) + return NULL; + if (!(*pfnGetNamedPipeServerProcessId)(hNamedPipe, &pid)) + return PyWin_SetAPIError("GetNamedPipeServerProcessId"); + return PyLong_FromUnsignedLong(pid); + } + %} + %native(GetNamedPipeClientProcessId) MyGetNamedPipeClientProcessId; + %native(GetNamedPipeServerProcessId) MyGetNamedPipeServerProcessId; + |
From: Roger U. <ru...@us...> - 2007-09-06 06:47:35
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21778/Pythonwin/pywin/scintilla Modified Files: control.py view.py Log Message: Get Pythonwin working on 64-bit Index: control.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/control.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** control.py 9 Oct 2004 01:33:48 -0000 1.14 --- control.py 6 Sep 2007 06:47:36 -0000 1.15 *************** *** 44,48 **** class ScintillaControlInterface: def SCIUnpackNotifyMessage(self, msg): ! format = "iiiiPiiiiiiiii" bytes = win32ui.GetBytes( msg, struct.calcsize(format) ) position, ch, modifiers, modificationType, text_ptr, \ --- 44,48 ---- class ScintillaControlInterface: def SCIUnpackNotifyMessage(self, msg): ! format = "iiiiPiiiPPiiii" bytes = win32ui.GetBytes( msg, struct.calcsize(format) ) position, ch, modifiers, modificationType, text_ptr, \ *************** *** 269,279 **** self.SendScintilla(win32con.WM_CLEAR) def FindText(self, flags, range, findText): buff = array.array('c', findText + "\0") addressBuffer = buff.buffer_info()[0] ! ft = struct.pack('llLll', range[0], range[1], addressBuffer, 0, 0) ftBuff = array.array('c', ft) addressFtBuff = ftBuff.buffer_info()[0] rc = self.SendScintilla(EM_FINDTEXTEX, flags, addressFtBuff) ! ftUnpacked = struct.unpack('llLll', ftBuff.tostring()) return rc, (ftUnpacked[3], ftUnpacked[4]) --- 269,289 ---- self.SendScintilla(win32con.WM_CLEAR) def FindText(self, flags, range, findText): + """ LPARAM for EM_FINDTEXTEX: + typedef struct _findtextex { + CHARRANGE chrg; + LPCTSTR lpstrText; + CHARRANGE chrgText;} FINDTEXTEX; + typedef struct _charrange { + LONG cpMin; + LONG cpMax;} CHARRANGE; + """ + findtextex_fmt='llPll' buff = array.array('c', findText + "\0") addressBuffer = buff.buffer_info()[0] ! ft = struct.pack(findtextex_fmt, range[0], range[1], addressBuffer, 0, 0) ftBuff = array.array('c', ft) addressFtBuff = ftBuff.buffer_info()[0] rc = self.SendScintilla(EM_FINDTEXTEX, flags, addressFtBuff) ! ftUnpacked = struct.unpack(findtextex_fmt, ftBuff.tostring()) return rc, (ftUnpacked[3], ftUnpacked[4]) *************** *** 339,343 **** buff = array.array('c', initer) addressBuffer = buff.buffer_info()[0] ! tr = struct.pack('llL', start, end, addressBuffer) trBuff = array.array('c', tr) addressTrBuff = trBuff.buffer_info()[0] --- 349,353 ---- buff = array.array('c', initer) addressBuffer = buff.buffer_info()[0] ! tr = struct.pack('llP', start, end, addressBuffer) trBuff = array.array('c', tr) addressTrBuff = trBuff.buffer_info()[0] Index: view.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/view.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** view.py 17 Dec 2006 21:38:27 -0000 1.25 --- view.py 6 Sep 2007 06:47:36 -0000 1.26 *************** *** 637,643 **** def FormatRange(self, dc, pageStart, lengthDoc, rc, draw): hdcRender = dc.GetHandleOutput() hdcFormat = dc.GetHandleAttrib() ! fr = struct.pack('llIIIIIIIIll', hdcRender, hdcFormat, rc[0], rc[1], rc[2], rc[3], rc[0], rc[1], rc[2], rc[3], pageStart, lengthDoc) frBuff = array.array('c', fr) addressFrBuff = frBuff.buffer_info()[0] --- 637,652 ---- def FormatRange(self, dc, pageStart, lengthDoc, rc, draw): + """ + typedef struct _formatrange { + HDC hdc; + HDC hdcTarget; + RECT rc; + RECT rcPage; + CHARRANGE chrg;} FORMATRANGE; + """ + fmt='PPIIIIIIIIll' hdcRender = dc.GetHandleOutput() hdcFormat = dc.GetHandleAttrib() ! fr = struct.pack(fmt, hdcRender, hdcFormat, rc[0], rc[1], rc[2], rc[3], rc[0], rc[1], rc[2], rc[3], pageStart, lengthDoc) frBuff = array.array('c', fr) addressFrBuff = frBuff.buffer_info()[0] |
From: Roger U. <ru...@us...> - 2007-09-06 06:47:35
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/docking In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21778/Pythonwin/pywin/docking Modified Files: DockingBar.py Log Message: Get Pythonwin working on 64-bit Index: DockingBar.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/docking/DockingBar.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DockingBar.py 2 Jul 2003 04:08:49 -0000 1.3 --- DockingBar.py 6 Sep 2007 06:47:36 -0000 1.4 *************** *** 162,166 **** return 0 lparam = msg[3] ! format = "iiiiiii" bytes = win32ui.GetBytes( lparam, struct.calcsize(format) ) hwnd, hwndAfter, x, y, cx, cy, flags = struct.unpack(format, bytes) --- 162,176 ---- return 0 lparam = msg[3] ! """ LPARAM used with WM_WINDOWPOSCHANGED: ! typedef struct { ! HWND hwnd; ! HWND hwndInsertAfter; ! int x; ! int y; ! int cx; ! int cy; ! UINT flags;} WINDOWPOS; ! """ ! format = "PPiiiii" bytes = win32ui.GetBytes( lparam, struct.calcsize(format) ) hwnd, hwndAfter, x, y, cx, cy, flags = struct.unpack(format, bytes) |
From: Roger U. <ru...@us...> - 2007-09-06 06:44:52
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20690/win32/Demos Modified Files: win32gui_menu.py Log Message: 64-bit fixes Index: win32gui_menu.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_menu.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32gui_menu.py 2 Jul 2006 23:30:12 -0000 1.4 --- win32gui_menu.py 6 Sep 2007 06:44:54 -0000 1.5 *************** *** 256,260 **** # we pretend we have more than that :) def OnMeasureItem(self, hwnd, msg, wparam, lparam): ! fmt = "6i" buf = PyMakeBuffer(struct.calcsize(fmt), lparam) data = struct.unpack(fmt, buf) --- 256,261 ---- # we pretend we have more than that :) def OnMeasureItem(self, hwnd, msg, wparam, lparam): ! ## Last item of MEASUREITEMSTRUCT is a ULONG_PTR ! fmt = "5iP" buf = PyMakeBuffer(struct.calcsize(fmt), lparam) data = struct.unpack(fmt, buf) *************** *** 284,288 **** def OnDrawItem(self, hwnd, msg, wparam, lparam): ! fmt = "12i" data = struct.unpack(fmt, PyGetString(lparam, struct.calcsize(fmt))) ctlType, ctlID, itemID, itemAction, itemState, hwndItem, \ --- 285,290 ---- def OnDrawItem(self, hwnd, msg, wparam, lparam): ! ## lparam is a DRAWITEMSTRUCT ! fmt = "5i2P4iP" data = struct.unpack(fmt, PyGetString(lparam, struct.calcsize(fmt))) ctlType, ctlID, itemID, itemAction, itemState, hwndItem, \ |
From: Roger U. <ru...@us...> - 2007-09-06 06:44:03
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20607/win32/Lib Modified Files: win32gui_struct.py Log Message: 64-bit fixes Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** win32gui_struct.py 2 Jul 2006 23:28:46 -0000 1.9 --- win32gui_struct.py 6 Sep 2007 06:44:05 -0000 1.10 *************** *** 44,48 **** # structure to avoid the caller needing to explicitly check validity # (None is used if the mask excludes/should exclude the value) ! menuitem_fmt = '9iP2i' def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, --- 44,48 ---- # structure to avoid the caller needing to explicitly check validity # (None is used if the mask excludes/should exclude the value) ! menuitem_fmt = '5i5PiP' def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, *************** *** 97,100 **** --- 97,101 ---- cch = 0 # Create the struct. + # 'P' format does not accept PyHANDLE's ! item = struct.pack( menuitem_fmt, *************** *** 104,114 **** fState, wID, ! hSubMenu, ! hbmpChecked, ! hbmpUnchecked, dwItemData, lptext, cch, ! hbmpItem ) # Now copy the string to a writable buffer, so that the result --- 105,115 ---- fState, wID, ! long(hSubMenu), ! long(hbmpChecked), ! long(hbmpUnchecked), dwItemData, lptext, cch, ! long(hbmpItem) ) # Now copy the string to a writable buffer, so that the result |
From: Roger U. <ru...@us...> - 2007-09-05 01:24:11
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31467/win32/src Modified Files: win32security.i Log Message: Add LogonUserEx, convert LogonUser to keyword args Better cleanup in SetTokenInformation Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** win32security.i 12 Aug 2007 08:16:29 -0000 1.45 --- win32security.i 5 Sep 2007 01:24:08 -0000 1.46 *************** *** 81,87 **** typedef BOOL (WINAPI *TranslateNamefunc)(LPCTSTR, EXTENDED_NAME_FORMAT, EXTENDED_NAME_FORMAT, LPTSTR, PULONG); static TranslateNamefunc pfnTranslateName=NULL; - typedef BOOL (WINAPI *CreateWellKnownSidfunc)(WELL_KNOWN_SID_TYPE, PSID, PSID, DWORD *); static CreateWellKnownSidfunc pfnCreateWellKnownSid=NULL; // function pointers used in win32security_sspi.cpp and win32security_ds.cpp --- 81,91 ---- typedef BOOL (WINAPI *TranslateNamefunc)(LPCTSTR, EXTENDED_NAME_FORMAT, EXTENDED_NAME_FORMAT, LPTSTR, PULONG); static TranslateNamefunc pfnTranslateName=NULL; typedef BOOL (WINAPI *CreateWellKnownSidfunc)(WELL_KNOWN_SID_TYPE, PSID, PSID, DWORD *); static CreateWellKnownSidfunc pfnCreateWellKnownSid=NULL; + typedef BOOL (WINAPI *LogonUserExfunc)(LPWSTR,LPWSTR,LPWSTR,DWORD,DWORD,PHANDLE,PSID*,PVOID*,LPDWORD,PQUOTA_LIMITS); + static LogonUserExfunc pfnLogonUserEx = NULL; + typedef BOOL (WINAPI *LogonUserExExfunc)(LPWSTR,LPWSTR,LPWSTR,DWORD,PTOKEN_GROUPS,DWORD,PHANDLE,PSID*,PVOID*,LPDWORD,PQUOTA_LIMITS); + static LogonUserExExfunc pfnLogonUserExEx = NULL; + // function pointers used in win32security_sspi.cpp and win32security_ds.cpp *************** *** 797,800 **** --- 801,806 ---- pfnImpersonateAnonymousToken=(ImpersonateAnonymousTokenfunc)loadapifunc("ImpersonateAnonymousToken", advapi32_dll); pfnIsTokenRestricted=(IsTokenRestrictedfunc)loadapifunc("IsTokenRestricted", advapi32_dll); + pfnLogonUserEx=(LogonUserExfunc)loadapifunc("LogonUserExW", advapi32_dll); + pfnLogonUserExEx=(LogonUserExExfunc)loadapifunc("LogonUserExExW", advapi32_dll); // Load InitSecurityInterface, which returns a table of pointers to the SSPI functions so they don't all have to be *************** *** 845,848 **** --- 851,856 ---- ||(strcmp(pmd->ml_name, "LsaAddAccountRights")==0) ||(strcmp(pmd->ml_name, "LsaRemoveAccountRights")==0) + ||(strcmp(pmd->ml_name, "LogonUser")==0) + ||(strcmp(pmd->ml_name, "LogonUserEx")==0) ){ pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; *************** *** 993,1005 **** BOOLAPI RevertToSelf(); // @pyswig <o PyHANDLE>|LogonUser|Attempts to log a user on to the local computer, that is, to the computer from which LogonUser was called. You cannot use LogonUser to log on to a remote computer. ! BOOLAPI LogonUser( ! TCHAR *userName, // @pyparm string|userName||The name of the user account to log on to. ! TCHAR *INPUT_NULLOK, // @pyparm string|domain||The name of the domain, or None for the current domain ! TCHAR *password, // @pyparm string|password||The password to use. ! DWORD logonType, // @pyparm int|logonType||Specifies the type of logon operation to perform. Must be a combination of the LOGON32_LOGON* constants. ! DWORD logonProvider, // @pyparm int|logonProvider||Specifies the logon provider to use. ! PyHANDLE *OUTPUT ! ); // @pyswig <o PySID>, string, int|LookupAccountName|Accepts the name of a system and an account as input. It retrieves a security identifier (SID) for the account and the name of the domain on which the account was found. --- 1001,1121 ---- BOOLAPI RevertToSelf(); + %native(LogonUser) pfn_PyLogonUser; + %native(LogonUserEx) pfn_PyLogonUserEx; + %{ // @pyswig <o PyHANDLE>|LogonUser|Attempts to log a user on to the local computer, that is, to the computer from which LogonUser was called. You cannot use LogonUser to log on to a remote computer. ! // @comm Accepts keyword args ! // @comm On Windows 2000 and earlier, the calling process must have SE_TCB_NAME privilege. ! PyObject *PyLogonUser(PyObject *self, PyObject *args, PyObject *kwargs) ! { ! DWORD logontype, logonprovider; ! PyObject *obusername, *obdomain, *obpassword; ! WCHAR *username=NULL, *domain=NULL, *password=NULL; ! HANDLE htoken; ! PyObject *ret=NULL; ! ! static char *keywords[]={"Username","Domain","Password","LogonType","LogonProvider", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOkk:LogonUser", keywords, ! &obusername, // @pyparm <o PyUnicode>|Username||The name of the user account to log on to. ! // This may also be a marshalled credential (see <om win32cred.CredMarshalCredential>). ! &obdomain, // @pyparm <o PyUnicode>|Domain||The name of the domain, or None for the current domain ! &obpassword, // @pyparm <o PyUnicode>|Password||User's password. Use a blank string if Username contains a marshalled credential. ! &logontype, // @pyparm int|LogonType||One of LOGON32_LOGON_* values ! &logonprovider)) // @pyparm int|LogonProvider||One of LOGON32_PROVIDER_* values ! return NULL; ! ! if (PyWinObject_AsWCHAR(obusername, &username, FALSE) ! &&PyWinObject_AsWCHAR(obdomain, &domain, TRUE) ! &&PyWinObject_AsWCHAR(obpassword, &password, FALSE)){ ! if (!LogonUser(username, domain, password, logontype, logonprovider, &htoken)) ! PyWin_SetAPIError("LogonUser"); ! else ! ret=PyWinObject_FromHANDLE(htoken); ! } ! ! if (password) ! SecureZeroMemory(password, wcslen(password)*sizeof(WCHAR)); ! PyWinObject_FreeWCHAR(username); ! PyWinObject_FreeWCHAR(domain); ! PyWinObject_FreeWCHAR(password); ! return ret; ! } ! ! PyObject *PyWinObject_FromQUOTA_LIMITS(PQUOTA_LIMITS pql) ! { ! return Py_BuildValue("{s:N, s:N, s:N, s:N, s:N, s:N}", ! "PagedPoolLimit", PyLong_FromUnsignedLongLong(pql->PagedPoolLimit), ! "NonPagedPoolLimit", PyLong_FromUnsignedLongLong(pql->NonPagedPoolLimit), ! "MinimumWorkingSetSize", PyLong_FromUnsignedLongLong(pql->MinimumWorkingSetSize), ! "MaximumWorkingSetSize", PyLong_FromUnsignedLongLong(pql->MaximumWorkingSetSize), ! "PagefileLimit", PyLong_FromUnsignedLongLong(pql->PagefileLimit), ! "TimeLimit", PyLong_FromUnsignedLongLong(pql->TimeLimit.QuadPart)); ! } ! ! // @pyswig (<o PyHANDLE>, <o PySID>, str, dict)|LogonUserEx|Log a user onto the local machine, ! // @comm Requires Windows XP or later ! // @comm Accepts keyword args ! // @rdesc Returns access token, logon sid, profile buffer, and process quotas. ! // Format of the profile buffer is not known, so returned object is subject to change. ! PyObject *PyLogonUserEx(PyObject *self, PyObject *args, PyObject *kwargs) ! { ! CHECK_PFN(LogonUserEx); ! DWORD logontype, logonprovider, profilelen; ! PyObject *obusername, *obdomain, *obpassword; ! WCHAR *username=NULL, *domain=NULL, *password=NULL; ! HANDLE htoken; ! void *profile=NULL; ! PSID psid=NULL; ! QUOTA_LIMITS quota_limits; ! PyObject *ret=NULL; ! ! static char *keywords[]={"Username","Domain","Password","LogonType","LogonProvider", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOkk:LogonUserEx", keywords, ! &obusername, // @pyparm <o PyUnicode>|Username||User account, may be specified as a UPN (us...@do...). ! // This may also be a marshalled credential (see <om win32cred.CredMarshalCredential>). ! &obdomain, // @pyparm <o PyUnicode>|Domain||User's domain. Can be None if Username is a full UPN. ! &obpassword, // @pyparm <o PyUnicode>|Password||User's password. Use a blank string if Username contains a marshalled credential. ! &logontype, // @pyparm int|LogonType||One of LOGON32_LOGON_* values ! &logonprovider)) // @pyparm int|LogonProvider||One of LOGON32_PROVIDER_* values ! return NULL; ! ! if (PyWinObject_AsWCHAR(obusername, &username, FALSE) ! &&PyWinObject_AsWCHAR(obdomain, &domain, TRUE) ! &&PyWinObject_AsWCHAR(obpassword, &password, FALSE)){ ! if (!LogonUserEx(username, domain, password, logontype, logonprovider, &htoken, ! &psid, &profile, &profilelen, "a_limits)) ! PyWin_SetAPIError("LogonUserEx"); ! else ! ret=Py_BuildValue("NNNN", ! PyWinObject_FromHANDLE(htoken), ! PyWinObject_FromSID(psid), ! PyString_FromStringAndSize((char *)profile, profilelen), ! PyWinObject_FromQUOTA_LIMITS("a_limits)); ! } ! ! // MSDN doesn't specify how the output buffers should be freed. The docs for LsaLogonUser ! // reference LsaFreeReturnBuffer, but it returns an error when trying to free the sid. ! // LsaFreeMemory succeeds for both buffers, so use it and warn if it returns an error ! NTSTATUS ntstatus; ! if (profile){ ! ntstatus=LsaFreeMemory(profile); ! if (ntstatus != ERROR_SUCCESS) ! PyErr_Warn(PyExc_RuntimeWarning, "Profile buffer could not be freed using LsaFreeMemory"); ! } ! if (psid){ ! ntstatus=LsaFreeMemory(psid); ! if (ntstatus != ERROR_SUCCESS) ! PyErr_Warn(PyExc_RuntimeWarning, "SID could not be freed using LsaFreeMemory"); ! } ! if (password) ! SecureZeroMemory(password, wcslen(password)*sizeof(WCHAR)); ! PyWinObject_FreeWCHAR(username); ! PyWinObject_FreeWCHAR(domain); ! PyWinObject_FreeWCHAR(password); ! return ret; ! } ! PyCFunction pfn_PyLogonUser=(PyCFunction)PyLogonUser; ! PyCFunction pfn_PyLogonUserEx=(PyCFunction)PyLogonUserEx; ! %} // @pyswig <o PySID>, string, int|LookupAccountName|Accepts the name of a system and an account as input. It retrieves a security identifier (SID) for the account and the name of the domain on which the account was found. *************** *** 1953,1957 **** // @pyswig <o PySECURITY_DESCRIPTOR>|GetFileSecurity|Obtains specified information about the security of a file or directory. The information obtained is constrained by the caller's access rights and privileges. // @comm This function reportedly will not return the INHERITED_ACE flag on some Windows XP SP1 systems ! // Use GetNameSecurityInfo if you encounter this problem. %native(GetFileSecurity) MyGetFileSecurity; %{ --- 2069,2073 ---- // @pyswig <o PySECURITY_DESCRIPTOR>|GetFileSecurity|Obtains specified information about the security of a file or directory. The information obtained is constrained by the caller's access rights and privileges. // @comm This function reportedly will not return the INHERITED_ACE flag on some Windows XP SP1 systems ! // Use GetNamedSecurityInfo if you encounter this problem. %native(GetFileSecurity) MyGetFileSecurity; %{ *************** *** 2187,2191 **** PyObject *obth; HANDLE th; ! PyObject *obinfo; DWORD bufsize = 0; void *buf = NULL; --- 2303,2307 ---- PyObject *obth; HANDLE th; ! PyObject *obinfo, *ret=NULL; DWORD bufsize = 0; void *buf = NULL; *************** *** 2209,2213 **** return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); if (!PyWinObject_AsSID(obinfo, &((PTOKEN_OWNER)buf)->Owner, FALSE)) ! return NULL; break; } --- 2325,2329 ---- return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); if (!PyWinObject_AsSID(obinfo, &((PTOKEN_OWNER)buf)->Owner, FALSE)) ! goto done; break; } *************** *** 2218,2222 **** return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); if (!PyWinObject_AsSID(obinfo, &((PTOKEN_PRIMARY_GROUP)buf)->PrimaryGroup, FALSE)) ! return NULL; break; } --- 2334,2338 ---- return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); if (!PyWinObject_AsSID(obinfo, &((PTOKEN_PRIMARY_GROUP)buf)->PrimaryGroup, FALSE)) ! goto done; break; } *************** *** 2227,2231 **** return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); if (!PyWinObject_AsACL(obinfo, &((PTOKEN_DEFAULT_DACL)buf)->DefaultDacl, TRUE)) ! return NULL; break; } --- 2343,2347 ---- return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); if (!PyWinObject_AsACL(obinfo, &((PTOKEN_DEFAULT_DACL)buf)->DefaultDacl, TRUE)) ! goto done; break; } *************** *** 2244,2248 **** PyErr_Clear(); PyErr_SetString(PyExc_TypeError, "Information must be an int >= 0"); ! return NULL; } break; --- 2360,2364 ---- PyErr_Clear(); PyErr_SetString(PyExc_TypeError, "Information must be an int >= 0"); ! goto done; } break; *************** *** 2254,2258 **** return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); if (!PyWinObject_AsSID_AND_ATTRIBUTES(obinfo, &((PTOKEN_MANDATORY_LABEL)buf)->Label)) ! return NULL; break; case TokenMandatoryPolicy: // @flag TokenMandatoryPolicy|Int. one of TOKEN_MANDATORY_POLICY_* values --- 2370,2374 ---- return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); if (!PyWinObject_AsSID_AND_ATTRIBUTES(obinfo, &((PTOKEN_MANDATORY_LABEL)buf)->Label)) ! goto done; break; case TokenMandatoryPolicy: // @flag TokenMandatoryPolicy|Int. one of TOKEN_MANDATORY_POLICY_* values *************** *** 2266,2286 **** PyErr_Clear(); PyErr_SetString(PyExc_TypeError, "Information must be an int >= 0"); ! return NULL; } break; #endif default: ! return PyErr_Format(PyExc_NotImplementedError, "TokenInformationClass %d is not yet supported", typ); } ! if (!SetTokenInformation(th,typ,buf,bufsize)){ ! free(buf); PyWin_SetAPIError("SetTokenInformation"); ! return NULL; } ! free(buf); ! Py_INCREF(Py_None); ! return Py_None; ! } %} --- 2382,2404 ---- PyErr_Clear(); PyErr_SetString(PyExc_TypeError, "Information must be an int >= 0"); ! goto done; } break; #endif default: ! PyErr_Format(PyExc_NotImplementedError, "TokenInformationClass %d is not yet supported", typ); ! goto done; } ! if (!SetTokenInformation(th,typ,buf,bufsize)) PyWin_SetAPIError("SetTokenInformation"); ! else{ ! Py_INCREF(Py_None); ! ret=Py_None; } ! done: ! if (buf) ! free(buf); ! return ret; } %} *************** *** 3957,3964 **** --- 4075,4086 ---- #define LOGON32_LOGON_SERVICE LOGON32_LOGON_SERVICE // Indicates a service-type logon. The account provided must have the service privilege enabled. #define LOGON32_LOGON_NETWORK LOGON32_LOGON_NETWORK // This logon type is intended for high performance servers to authenticate clear text passwords. LogonUser does not cache credentials for this logon type. This is the fastest logon path, but there are two limitations. First, the function returns an impersonation token, not a primary token. You cannot use this token directly in the CreateProcessAsUser function. However, you can call the DuplicateTokenEx function to convert the token to a primary token, and then use it in CreateProcessAsUser. Second, if you convert the token to a primary token and use it in CreateProcessAsUser to start a process, the new process will not be able to access other network resources, such as remote servers or printers, through the redirector. + #define LOGON32_LOGON_UNLOCK LOGON32_LOGON_UNLOCK + #define LOGON32_LOGON_NETWORK_CLEARTEXT LOGON32_LOGON_NETWORK_CLEARTEXT + #define LOGON32_LOGON_NEW_CREDENTIALS LOGON32_LOGON_NEW_CREDENTIALS #define LOGON32_PROVIDER_DEFAULT LOGON32_PROVIDER_DEFAULT // Use the standard logon provider for the system. This is the recommended value for the dwLogonProvider parameter. It provides maximum compatibility with current and future releases of Windows NT. #define LOGON32_PROVIDER_WINNT40 LOGON32_PROVIDER_WINNT40 // Use the Windows NT 4.0 logon provider #define LOGON32_PROVIDER_WINNT35 LOGON32_PROVIDER_WINNT35 // Use the Windows NT 3.5 logon provider. + #define LOGON32_PROVIDER_WINNT50 LOGON32_PROVIDER_WINNT50 // Use the Negotiate protocol // SECURITY_IDENTIFIER_AUTHORITY Values ??? last byte of a 6 - byte array ??? |
From: Mark H. <mha...@us...> - 2007-09-04 10:53:29
|
Update of /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7696/com/TestSources/PyCOMTest Modified Files: PyCOMImpl.cpp PyCOMImpl.h PyCOMTest.idl Log Message: Much better support for 'named params' in Python gateways. Fixes [ 1648655 ] Wrong args order with event handler Index: PyCOMTest.idl =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMTest.idl,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PyCOMTest.idl 11 Feb 2007 12:39:05 -0000 1.15 --- PyCOMTest.idl 4 Sep 2007 10:53:29 -0000 1.16 *************** *** 294,297 **** --- 294,298 ---- import "oaidl.idl"; HRESULT Fire([in]long nID); + HRESULT FireWithNamedParams([in]long nID, [in]QsBoolean b, [in, out]int *outVal, [in, out]int *outVal2); }; [ Index: PyCOMImpl.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMImpl.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyCOMImpl.h 11 Feb 2007 12:39:05 -0000 1.14 --- PyCOMImpl.h 4 Sep 2007 10:53:29 -0000 1.15 *************** *** 85,88 **** --- 85,89 ---- // method to broadcast a call on the current connections STDMETHOD(Fire)(long nID); + STDMETHOD(FireWithNamedParams)(long nID, QsBoolean b, int *outVal1, int *outVal2); STDMETHOD(TestOptionals)(BSTR strArg, short sarg, long larg, double darg, SAFEARRAY **pRet); STDMETHOD(TestOptionals2)(double dval, BSTR strval, short sval, SAFEARRAY **pRet); Index: PyCOMImpl.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/TestSources/PyCOMTest/PyCOMImpl.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PyCOMImpl.cpp 11 Feb 2007 12:39:05 -0000 1.15 --- PyCOMImpl.cpp 4 Sep 2007 10:53:29 -0000 1.16 *************** *** 323,328 **** *counter = new CCounter(); - (*counter)->AddRef(); if (*counter==NULL) return E_OUTOFMEMORY; return S_OK; } --- 323,328 ---- *counter = new CCounter(); if (*counter==NULL) return E_OUTOFMEMORY; + (*counter)->AddRef(); return S_OK; } *************** *** 361,365 **** CComVariant v(nID); DISPPARAMS params = { &v, NULL, 1, 0 }; ! pEvent->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); } // IPyCOMTestEvent* pIEvent = (IPyCOMTestEvent*)*pp; --- 361,476 ---- CComVariant v(nID); DISPPARAMS params = { &v, NULL, 1, 0 }; ! hr = pEvent->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); ! } ! if (FAILED(hr)) ! break; ! // call FireWithNamedParams a variety of ways. ! // See http://msdn2.microsoft.com/en-us/library/ms221653.aspx ! // "Passing Parameters (Component Automation)" for details. ! ! OLECHAR *names2[] = { L"OnFireWithNamedParams" }; ! hr = pEvent->GetIDsOfNames(IID_NULL, names2, 1, 0, &dispid); ! if (SUCCEEDED(hr)) { ! // First call without named params - order is reversed ! // (ie, last in array is first presented to Python.) ! LONG out_result1 = nID+1; ! LONG out_result2 = nID+2; ! CComVariant v[4]; ! // the "out2" outVal; ! V_VT(&v[0]) = VT_I4 | VT_BYREF; ! v[0].plVal = &out_result2; ! // the "out1" outVal; ! V_VT(&v[1]) = VT_I4 | VT_BYREF; ! v[1].plVal = &out_result1; ! // the bool ! v[2] = VARIANT_TRUE; // the bool ! V_VT(&v[2]) = VT_BOOL; ! // the first param. ! v[3] = nID; ! DISPPARAMS params = { v, NULL, 4, 0 }; ! hr = pEvent->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); ! // all known impls return these values in the out pointer. ! _ASSERTE(out_result1==nID+3); ! _ASSERTE(out_result2==nID+4); ! } ! // Now with various combinations of named args. Like Python, this ! // assumes that param DISPIDs start with zero, are sequential and ! // in the same order as the IDL signature. ! if (SUCCEEDED(hr)) { ! // Call again - this time with named params. ! LONG out_result1 = nID+1; ! LONG out_result2 = nID+2; ! CComVariant v[4]; ! ! // the "out2" outVal; ! V_VT(&v[3]) = VT_I4 | VT_BYREF; ! v[3].plVal = &out_result2; ! // the "out1" outVal; ! V_VT(&v[2]) = VT_I4 | VT_BYREF; ! v[2].plVal = &out_result1; ! // the bool ! v[1] = VARIANT_TRUE; // the bool ! V_VT(&v[1]) = VT_BOOL; ! // the first param. ! v[0] = nID; ! // Build 210 and earlier, this was the only way params *could* be passed, ! // which happily was the same way MSOffice did it. ! DISPID namedIDs[4] = {0, 1, 2, 3}; ! DISPPARAMS params = { v, namedIDs, 4, 4 }; ! hr = pEvent->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); ! // all known impls return nID+1 in the out pointer. ! _ASSERTE(out_result1==nID+3); ! _ASSERTE(out_result2==nID+4); ! } ! // Try some other funky combinations to mess with Python :) ! if (SUCCEEDED(hr)) { ! // First 2 positional, 2nd 2 by name. ! LONG out_result1 = nID+1; ! LONG out_result2 = nID+2; ! ! CComVariant v[4]; ! // the first param. ! v[3] = nID; ! // 2nd positional ! v[2] = VARIANT_TRUE; // the bool ! V_VT(&v[2]) = VT_BOOL; ! // named ones up front. ! ! // the "out2" outVal (dispid=3) ! V_VT(&v[1]) = VT_I4 | VT_BYREF; ! v[1].plVal = &out_result2; ! // the "out1" outVal (dispid=2) ! V_VT(&v[0]) = VT_I4 | VT_BYREF; ! v[0].plVal = &out_result1; ! ! DISPID namedIDs[2] = {2, 3}; ! DISPPARAMS params = { v, namedIDs, 4, 2 }; ! hr = pEvent->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); ! // all known impls return nID+1 in the out pointer. ! _ASSERTE(out_result1==nID+3); ! _ASSERTE(out_result2==nID+4); ! } ! ! if (SUCCEEDED(hr)) { ! // Only pass the 2 out params - Python must ensure earlier ! // ones are also passed. ! LONG out_result1 = nID+1; ! LONG out_result2 = nID+2; ! ! CComVariant v[4]; ! // the "out2" outVal (dispid=3) ! V_VT(&v[0]) = VT_I4 | VT_BYREF; ! v[0].plVal = &out_result2; ! // the "out1" outVal (dispid=2) ! V_VT(&v[1]) = VT_I4 | VT_BYREF; ! v[1].plVal = &out_result1; ! ! DISPID namedIDs[2] = {3, 2}; ! DISPPARAMS params = { v, namedIDs, 2, 2 }; ! ! hr = pEvent->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL); ! // all known impls return nID+1 in the out pointer. ! _ASSERTE(out_result1==nID+3); ! _ASSERTE(out_result2==nID+4); } // IPyCOMTestEvent* pIEvent = (IPyCOMTestEvent*)*pp; *************** *** 369,375 **** --- 480,497 ---- } Unlock(); + _ASSERTE(SUCCEEDED(hr)); return hr; } + HRESULT CPyCOMTest::FireWithNamedParams(long nID, VARIANT_BOOL b, int *outVal1, int *outVal2) + { + _ASSERTE(b==VARIANT_TRUE); + _ASSERTE(nID+1==*outVal1); + _ASSERTE(nID+2==*outVal2); + *outVal1 = (int)nID+3; + *outVal2 = (int)nID+4; + return S_OK; + } + HRESULT CPyCOMTest::TestOptionals(BSTR strArg, short sarg, long larg, double darg, SAFEARRAY **pRet) { |
From: Mark H. <mha...@us...> - 2007-09-04 10:53:28
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7696/com/win32com/src Modified Files: PyGatewayBase.cpp PythonCOM.cpp Log Message: Much better support for 'named params' in Python gateways. Fixes [ 1648655 ] Wrong args order with event handler Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** PythonCOM.cpp 27 Aug 2007 05:12:11 -0000 1.48 --- PythonCOM.cpp 4 Sep 2007 10:53:29 -0000 1.49 *************** *** 29,35 **** extern PyObject *g_obPyCom_MapInterfaceNameToIID; ! static PyObject *g_obEmpty = NULL; ! static PyObject *g_obMissing = NULL; ! static PyObject *g_obArgNotFound = NULL; PyObject *PyCom_InternalError = NULL; --- 29,35 ---- extern PyObject *g_obPyCom_MapInterfaceNameToIID; ! PyObject *g_obEmpty = NULL; ! PyObject *g_obMissing = NULL; ! PyObject *g_obArgNotFound = NULL; PyObject *PyCom_InternalError = NULL; Index: PyGatewayBase.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyGatewayBase.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PyGatewayBase.cpp 19 Apr 2006 22:37:56 -0000 1.16 --- PyGatewayBase.cpp 4 Sep 2007 10:53:29 -0000 1.17 *************** *** 12,18 **** --- 12,26 ---- { 0x25d29cd0, 0x9b98, 0x11d0, { 0xae, 0x79, 0x4c, 0xf1, 0xcf, 0x0, 0x0, 0x0 } }; + extern PyObject *g_obMissing; + extern void PyCom_LogF(const char *fmt, ...); #define LogF PyCom_LogF + #include <malloc.h> + #if _MSC_VER < 1400 + // _malloca is the new 'safe' one + #define _malloca _alloca + #endif + // Internal ErrorUtil helpers we reach in for. // Free the strings from an excep-info. *************** *** 342,347 **** } ! UINT count = PyObject_Length(result); ! if ( count != cNames ) { PyErr_Clear(); /* ### toss any potential exception */ --- 350,355 ---- } ! Py_ssize_t count = PyObject_Length(result); ! if ( count != PyWin_SAFE_DOWNCAST(cNames, UINT, Py_ssize_t)) { PyErr_Clear(); /* ### toss any potential exception */ *************** *** 409,413 **** ) { ! PyObject *argList = PyTuple_New(params->cArgs); if ( !argList ) { --- 417,445 ---- ) { ! HRESULT hr = S_OK; ! PyObject * py_lcid = NULL; ! /* Our named arg support is based on a few things. First, ! GetIDsOfNames() documentation states all params are numbered 0->n. ! Secondly, we have always required that all args be present in the ! Python implementation, and the names of those args need not be ! identical to the names in a typelib. Given these 2 facts, we can ! safely treat dispids as indexes into our arg tuple. ! */ ! // num args is the greatest of cArgs and all the dispIDs presented. ! UINT i; ! UINT numArgs = params->cArgs; ! // handle 1 special case: 1 named arg with dispid of DISPID_PROPERTYPUT ! // We just treat that as positional, so it ends up at the end (which is ! // what we always did) ! UINT numNamedArgs = params->cNamedArgs!=1 || params->rgdispidNamedArgs[0]!=DISPID_PROPERTYPUT ? params->cNamedArgs : 0; ! ! for (i=0;i<numNamedArgs;i++) { ! // make sure its not a special DISPID we don't understand. ! if (params->rgdispidNamedArgs[i] < 0) ! return DISP_E_PARAMNOTFOUND; ! numArgs = max(numArgs, (UINT)params->rgdispidNamedArgs[i]+1); ! } ! ! PyObject *argList = PyTuple_New(numArgs); if ( !argList ) { *************** *** 415,443 **** return E_OUTOFMEMORY; } ! PyObject *ob; ! VARIANTARG FAR *pvarg; ! UINT i; ! for ( pvarg = params->rgvarg, i = params->cArgs; i--; ++pvarg ) ! { ! ob = PyCom_PyObjectFromVariant(pvarg); ! if ( !ob ) ! { ! PyErr_Clear(); /* ### what to do with exceptions? ... */ ! Py_DECREF(argList); ! return E_OUTOFMEMORY; } ! /* Note: this takes our reference for us (even if it fails) */ ! if ( PyTuple_SetItem(argList, i, ob) == -1 ) ! { ! PyErr_Clear(); /* ### what to do with exceptions? ... */ ! Py_DECREF(argList); ! return E_FAIL; } } /* use the double stuff to keep lcid unsigned... */ ! PyObject * py_lcid = PyLong_FromDouble((double)lcid); if ( !py_lcid ) { --- 447,492 ---- return E_OUTOFMEMORY; } + // MUST exit from here on error via 'failed:' ! // Fill the positional args - they start at the end. ! for ( i = params->cArgs; i != numNamedArgs; --i) { ! PyObject *ob = PyCom_PyObjectFromVariant(params->rgvarg+i-1); ! if ( !ob ) { ! hr = E_OUTOFMEMORY; ! goto failed; } ! Py_ssize_t pyndx = params->cArgs - i; // index in Python arg tuple. /* Note: this takes our reference for us (even if it fails) */ ! if ( PyTuple_SetItem(argList, pyndx, ob) == -1 ) { ! hr = E_FAIL; ! goto failed; ! } ! } ! // Fill the named params. ! for (i=0;i<numNamedArgs;i++) { ! UINT ndx = params->rgdispidNamedArgs[i]; ! assert(PyTuple_GET_ITEM(argList, ndx)==NULL); // must not have seen it before ! PyObject *ob = PyCom_PyObjectFromVariant(params->rgvarg+i); ! if ( !ob ) { ! hr = E_OUTOFMEMORY; ! goto failed; ! } ! /* Note: this takes our reference for us (even if it fails) */ ! if ( PyTuple_SetItem(argList, ndx, ob) == -1 ) { ! hr = E_FAIL; ! goto failed; ! } ! } ! // and any ones missing get 'Missing' - all positional ones must ! // have been done ! for (i=params->cArgs-numNamedArgs;i < numArgs;i++) { ! if (PyTuple_GET_ITEM(argList, i)==NULL) { ! Py_INCREF(g_obMissing); ! PyTuple_SetItem(argList, i, g_obMissing); } } /* use the double stuff to keep lcid unsigned... */ ! py_lcid = PyLong_FromDouble((double)lcid); if ( !py_lcid ) { *************** *** 449,453 **** *pPyArgList = argList; *pPyLCID = py_lcid; ! return S_OK; } --- 498,578 ---- *pPyArgList = argList; *pPyLCID = py_lcid; ! return hr; ! failed: ! PyCom_LoggerException(NULL, "Failed to setup call into Python gateway"); ! PyErr_Clear(); ! Py_DECREF(argList); ! assert(FAILED(hr)); // must have set this. ! return hr; ! } ! ! // Named support for [out] args is harder - utilities for sorting ! struct NPI { ! DISPID id; ! VARIANT *v; ! unsigned offset; ! }; ! ! int qsort_compare( const void *arg1, const void *arg2 ) ! { ! // NOTE: We return in DESCENDING order ! return ((NPI *)arg2)->id - ((NPI *)arg1)->id; ! } ! ! // Given the COM params, fill a caller-allocated array of indexes into the ! // params for all the BYREF's. -1 will be set for all non-byref args. ! // The array to fill should be the same size as pDispParams->cArgs. ! // Example: if all args are positional and BYREF, pOffsets will be filled ! // with [3, 2, 1, 0] - indicating pDispParams->rgvarg[3] is the first BYREF, ! // and rgvarg[0] is the last. Another example: only last param is BYREF, ! // pOffsets will be filled with [0, -1, -1, -1]. ! // Named params are tricky - IDs could be in any order, but the tuple order ! // is fixed - so we sort the named params by their ID to work out the order. ! static void fill_byref_offsets(DISPPARAMS *pDispParams, unsigned *pOffsets, unsigned noffsets) ! { ! // See above - special case DISPID_PROPERTYPUT. All other negative ! // DISPIDs have already been rejected. ! UINT numNamedArgs = pDispParams->cNamedArgs!=1 || pDispParams->rgdispidNamedArgs[0]!=DISPID_PROPERTYPUT ? pDispParams->cNamedArgs : 0; ! // init all. ! memset(pOffsets, -1, noffsets * sizeof(unsigned)); ! unsigned ioffset = 0; ! unsigned idispparam; ! // positional args are in reverse order ! for (idispparam=pDispParams->cArgs; ! idispparam > numNamedArgs && ioffset < noffsets; ! idispparam--) { ! VARIANT *pv = pDispParams->rgvarg+idispparam-1; ! // If this param is not byref, try the following one. ! if (!V_ISBYREF(pv)) ! continue; ! pOffsets[ioffset] = idispparam-1; ! ioffset++; ! } ! // named params could have their dispid in any order - so we sort ! // them - but only if necessary ! if (numNamedArgs && ioffset < noffsets) { ! // NOTE: optimizations possible - if only 1 named param its ! // obvious which one it is! If 2 params its very easy to work ! // it out - so we should only qsort for 3 or more. ! NPI *npi = (NPI *)_malloca(sizeof(NPI) * pDispParams->cNamedArgs); // death if we fail :) ! for (unsigned i=0;i < pDispParams->cNamedArgs;i++) { ! npi[i].id = pDispParams->rgdispidNamedArgs[i]; ! npi[i].v = &pDispParams->rgvarg[i]; ! npi[i].offset = i; ! } ! qsort(npi, pDispParams->cNamedArgs, sizeof(NPI), qsort_compare); ! // Now in descending order - we can just do the same loop again, ! // using our sorted array instead of the original. ! for (; ! idispparam > 0 && ioffset < noffsets; ! idispparam--) { ! VARIANT *pv = npi[idispparam-1].v; ! // If this param is not byref, try the following one. ! if (!V_ISBYREF(pv)) ! continue; ! pOffsets[ioffset] = npi[idispparam-1].offset; ! ioffset++; ! } ! } } *************** *** 490,494 **** ob = NULL; ! int count = PyObject_Length(result); if ( count > 0 ) { --- 615,619 ---- ob = NULL; ! Py_ssize_t count = PyObject_Length(result); if ( count > 0 ) { *************** *** 523,527 **** // from the same function. if (PyTuple_Check(userResult)) { ! unsigned cUserResult = PyTuple_Size(userResult); unsigned firstByRef = 0; if ( pVarResult ) --- 648,652 ---- // from the same function. if (PyTuple_Check(userResult)) { ! unsigned cUserResult = PyWin_SAFE_DOWNCAST(PyTuple_Size(userResult), Py_ssize_t, UINT); unsigned firstByRef = 0; if ( pVarResult ) *************** *** 534,551 **** firstByRef = 1; } // Now loop over the params, and set any byref's ! unsigned ituple = firstByRef; ! unsigned idispparam; ! // args are in reverse order ! for (idispparam=pDispParams->cArgs;idispparam>0;idispparam--) { ! // If we havent been given enough values, then we are done. ! if (ituple >= cUserResult) break; ! VARIANT *pv = pDispParams->rgvarg+idispparam-1; ! // If this param is not byref, try the following one. ! if (!V_ISBYREF(pv)) ! continue; // Do the conversion thang ! ob = PyTuple_GetItem(userResult, ituple); if (!ob) goto done; Py_INCREF(ob); // tuple fetch doesnt do this! --- 659,680 ---- firstByRef = 1; } + UINT max_args = min(cUserResult-firstByRef, pDispParams->cArgs); + UINT *offsets = (UINT *)_malloca(sizeof(UINT) * max_args); + // Get the offsets into our params of all BYREF args, in order. + fill_byref_offsets(pDispParams, offsets, max_args); + // Now loop over the params, and set any byref's ! UINT i; ! for (i=0;i<max_args;i++) { ! UINT offset = offsets[i]; ! if (offset == (UINT)-1) { ! // we've more args than BYREFs. ! PyCom_LoggerWarning(NULL, "Too many results supplied - %d supplied, but only %d can be set", cUserResult, i); break; ! } ! VARIANT *pv = pDispParams->rgvarg+offset; ! assert(V_ISBYREF(pv)); // Do the conversion thang ! ob = PyTuple_GetItem(userResult, i + firstByRef); if (!ob) goto done; Py_INCREF(ob); // tuple fetch doesnt do this! *************** *** 555,559 **** arghelper.m_convertDirection = POAH_CONVERT_FROM_VARIANT; if (!arghelper.MakeObjToVariant(ob, pv)) goto done; - ituple++; Py_DECREF(ob); ob = NULL; --- 684,687 ---- *************** *** 566,577 **** // If a Python error, it remains set for handling below... } else { ! // Single value for the first byref we find. ! unsigned idispparam; ! // args are in reverse order ! for (idispparam=pDispParams->cArgs;idispparam>0;idispparam--) { ! VARIANT *pv = pDispParams->rgvarg+idispparam-1; ! if (!V_ISBYREF(pv)) ! continue; ! PythonOleArgHelper arghelper; arghelper.m_reqdType = V_VT(pv); --- 694,705 ---- // If a Python error, it remains set for handling below... } else { ! // Single value for the first byref we find. Probably ! // only 1, but do the whole byref processing to ensure ! // if there is more than 1, we get the right 1. ! UINT offset; ! fill_byref_offsets(pDispParams, &offset, 1); ! if (offset != (UINT)-1) { ! VARIANT *pv = pDispParams->rgvarg+offset; ! assert(V_ISBYREF(pv)); PythonOleArgHelper arghelper; arghelper.m_reqdType = V_VT(pv); *************** *** 579,583 **** arghelper.MakeObjToVariant(userResult, pv); // If a Python error, it remains set for handling below... - break; } } --- 707,710 ---- *************** *** 616,635 **** V_VT(pVarResult) = VT_EMPTY; - /* ### for now: no named args unless it is a PUT operation, - ### OR all args are named args, and have contiguous DISPIDs - */ - if ( params->cNamedArgs ) - { - if ( params->cNamedArgs != 1 || params->rgdispidNamedArgs[0] != DISPID_PROPERTYPUT ) { - if (params->cArgs != params->cNamedArgs) - // Not all named args. - return DISP_E_NONAMEDARGS; - unsigned int argCheck; - for (argCheck=0;argCheck<params->cNamedArgs;argCheck++) - if (params->rgdispidNamedArgs[argCheck] != (DISPID)argCheck) - return DISP_E_NONAMEDARGS; - // OK - we will let it through. - } - } PY_GATEWAY_METHOD; PyObject *argList; --- 743,746 ---- *************** *** 695,714 **** V_VT(pVarResult) = VT_EMPTY; - /* ### for now: no named args unless it is a PUT operation, - ### OR all args are named args, and have contiguous DISPIDs - */ - if ( params->cNamedArgs ) - { - if ( params->cNamedArgs != 1 || params->rgdispidNamedArgs[0] != DISPID_PROPERTYPUT ) { - if (params->cArgs != params->cNamedArgs) - // Not all named args. - return DISP_E_NONAMEDARGS; - unsigned int argCheck; - for (argCheck=0;argCheck<params->cNamedArgs;argCheck++) - if (params->rgdispidNamedArgs[argCheck] != (DISPID)argCheck) - return DISP_E_NONAMEDARGS; - // OK - we will let it through. - } - } PY_GATEWAY_METHOD; PyObject *obISP = PyCom_PyObjectFromIUnknown(pspCaller, IID_IServiceProvider, TRUE); --- 806,809 ---- |
From: Mark H. <mha...@us...> - 2007-09-04 10:53:28
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7696/com/win32com/test Modified Files: testPyComTest.py Log Message: Much better support for 'named params' in Python gateways. Fixes [ 1648655 ] Wrong args order with event handler Index: testPyComTest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testPyComTest.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** testPyComTest.py 11 Feb 2007 12:39:06 -0000 1.27 --- testPyComTest.py 4 Sep 2007 10:53:29 -0000 1.28 *************** *** 67,73 **** except KeyError: self.fireds[no] = 0 def _DumpFireds(self): if not self.fireds: ! print "ERROR: Nothing was recieved!" for firedId, no in self.fireds.items(): progress("ID %d fired %d times" % (firedId, no)) --- 67,86 ---- except KeyError: self.fireds[no] = 0 + def OnFireWithNamedParams(self, no, a_bool, out1, out2): + # This test exists mainly to help with an old bug, where named + # params would come in reverse. + # We know our impl called 'OnFire' with the same ID + Missing = pythoncom.Missing + if no is not Missing: + assert no in self.fireds + assert no+1==out1, "expecting 'out1' param to be ID+1" + assert no+2==out2, "expecting 'out2' param to be ID+2" + # The middle must be a boolean. + assert a_bool is Missing or type(a_bool)==bool, "middle param not a bool" + return out1+2, out2+2 + def _DumpFireds(self): if not self.fireds: ! print "ERROR: Nothing was received!" for firedId, no in self.fireds.items(): progress("ID %d fired %d times" % (firedId, no)) |
From: Mark H. <mha...@us...> - 2007-09-04 10:32:08
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32199/include Modified Files: PythonCOM.h Log Message: add a "warning" capability Index: PythonCOM.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PythonCOM.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** PythonCOM.h 3 Jun 2007 09:46:37 -0000 1.25 --- PythonCOM.h 4 Sep 2007 10:32:05 -0000 1.26 *************** *** 320,328 **** // NOTE: By default, win32com does *not* provide a logger, so default is that // all errors are written to stdout. PYCOM_EXPORT void PyCom_LoggerNonServerException(PyObject *logProvider, ! const char *fmt, ...); PYCOM_EXPORT void PyCom_LoggerException(PyObject *logProvider, const char *fmt, ...); // Server related error functions // These are supplied so that any Python errors we detect can be --- 320,338 ---- // NOTE: By default, win32com does *not* provide a logger, so default is that // all errors are written to stdout. + // This will *not* write a record if a COM Server error is current. PYCOM_EXPORT void PyCom_LoggerNonServerException(PyObject *logProvider, ! const char *fmt, ...); + // Write an error record, including exception. This will write an error + // record even if a COM server error is current. PYCOM_EXPORT void PyCom_LoggerException(PyObject *logProvider, const char *fmt, ...); + // Write a warning record - in general this does *not* mean a call failed, but + // still is something in the programmers control that they should change. + // XXX - if an exception is pending when this is called, the traceback will + // also be written. This is undesirable and will be changed should this + // start being a problem. + PYCOM_EXPORT void PyCom_LoggerWarning(PyObject *logProvider, const char *fmt, ...); + // Server related error functions // These are supplied so that any Python errors we detect can be |
From: Mark H. <mha...@us...> - 2007-09-04 10:32:08
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32199 Modified Files: ErrorUtils.cpp Log Message: add a "warning" capability Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** ErrorUtils.cpp 7 May 2007 02:33:00 -0000 1.29 --- ErrorUtils.cpp 4 Sep 2007 10:32:03 -0000 1.30 *************** *** 576,582 **** // the "logger" module and my dumb choice of _DoLogger() for logger errors :) // Thankfully both are private. ! static void _DoLogError(const char *fmt, va_list argptr) { ! PyCom_StreamMessage("pythoncom error: "); VLogF(fmt, argptr); PyCom_StreamMessage("\n"); --- 576,582 ---- // the "logger" module and my dumb choice of _DoLogger() for logger errors :) // Thankfully both are private. ! static void _DoLogError(const char *prefix, const char *fmt, va_list argptr) { ! PyCom_StreamMessage(prefix); VLogF(fmt, argptr); PyCom_StreamMessage("\n"); *************** *** 598,601 **** --- 598,606 ---- PyErr_Fetch( &exc_typ, &exc_val, &exc_tb); PyObject *logger = NULL; + char prefix[128]; + strcpy(prefix, "pythoncom "); + strncat(prefix, log_method, 100); + strncat(prefix, ": ", 2); + if (logProvider) logger = PyObject_CallMethod(logProvider, "_GetLogger_", NULL); *************** *** 614,631 **** PyErr_Restore(exc_typ, exc_val, exc_tb); if (!logger || ! !VLogF_Logger(logger, log_method, "pythoncom error: ", fmt, argptr)) // No logger, or logger error - normal stdout stream. ! _DoLogError(fmt, argptr); Py_XDECREF(logger); } - PYCOM_EXPORT - void PyCom_LogError(const char *fmt, ...) - { - va_list marker; - va_start(marker, fmt); - _DoLogger(NULL, "error", fmt, marker); - } - BOOL IsNonServerErrorCurrent() { BOOL rc = FALSE; --- 619,628 ---- PyErr_Restore(exc_typ, exc_val, exc_tb); if (!logger || ! !VLogF_Logger(logger, log_method, prefix, fmt, argptr)) // No logger, or logger error - normal stdout stream. ! _DoLogError(prefix, fmt, argptr); Py_XDECREF(logger); } BOOL IsNonServerErrorCurrent() { BOOL rc = FALSE; *************** *** 649,652 **** --- 646,656 ---- } + PYCOM_EXPORT void PyCom_LoggerWarning(PyObject *logProvider, const char *fmt, ...) + { + va_list marker; + va_start(marker, fmt); + _DoLogger(logProvider, "warning", fmt, marker); + } + PYCOM_EXPORT void PyCom_LoggerNonServerException(PyObject *logProvider, const char *fmt, ...) |
From: Mark H. <mha...@us...> - 2007-09-04 06:04:12
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32711/src/extensions Modified Files: PyGStream.cpp PyILockBytes.cpp Log Message: Clarify which interface threw a ValueError Index: PyGStream.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyGStream.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyGStream.cpp 3 Jul 2007 21:00:46 -0000 1.5 --- PyGStream.cpp 4 Sep 2007 06:04:13 -0000 1.6 *************** *** 23,27 **** if (PyWinObject_AsReadBuffer(result, &buf, &resultlen, FALSE)){ if (resultlen > cb) ! PyErr_SetString(PyExc_ValueError,"Returned data longer than requested"); else{ memcpy(pv, buf, resultlen); --- 23,27 ---- if (PyWinObject_AsReadBuffer(result, &buf, &resultlen, FALSE)){ if (resultlen > cb) ! PyErr_SetString(PyExc_ValueError,"PyGStream::Read: returned data longer than requested"); else{ memcpy(pv, buf, resultlen); Index: PyILockBytes.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyILockBytes.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyILockBytes.cpp 4 Jul 2007 16:43:37 -0000 1.4 --- PyILockBytes.cpp 4 Sep 2007 06:04:13 -0000 1.5 *************** *** 256,260 **** if (PyWinObject_AsReadBuffer(result, &buf, &resultlen, FALSE)){ if (resultlen > cb) ! PyErr_SetString(PyExc_ValueError,"Returned data longer than requested"); else{ memcpy(pv, buf, resultlen); --- 256,260 ---- if (PyWinObject_AsReadBuffer(result, &buf, &resultlen, FALSE)){ if (resultlen > cb) ! PyErr_SetString(PyExc_ValueError,"PyGLockBytes::ReadAt: returned data longer than requested"); else{ memcpy(pv, buf, resultlen); |
From: Mark H. <mha...@us...> - 2007-09-03 07:11:04
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18218 Modified Files: win32gui.i Log Message: Add PtInRect Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.110 retrieving revision 1.111 diff -C2 -d -r1.110 -r1.111 *** win32gui.i 3 Jun 2007 14:53:07 -0000 1.110 --- win32gui.i 3 Sep 2007 05:01:59 -0000 1.111 *************** *** 476,479 **** --- 476,484 ---- } + %typemap(python,in) POINT INPUT { + if (!PyWinObject_AsPOINT($source, &$target)) + return NULL; + } + %typemap(python,in) POINT *BOTH = POINT *INPUT; *************** *** 5290,5293 **** --- 5295,5303 ---- int Y); // @pyparm int|Y||Y coord + // @pyswig boolean|PtInRect|Determines if a rectangle contains a point + BOOL PtInRect( + RECT *INPUT, // @pyparm (int, int, int, int)|rect||The rect to check + POINT INPUT); // @pyparm (int,int)|point||The point + // @pyswig boolean|RectInRegion|Determines if a region and rectangle overlap at any point BOOL RectInRegion( |