pywin32-checkins Mailing List for Python for Windows Extensions (Page 99)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Roger U. <ru...@us...> - 2006-12-10 21:51:56
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/Demos/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22506/Pythonwin/pywin/Demos/app Modified Files: basictimerapp.py dlgappdemo.py Log Message: Remove obsolete regsub module Index: dlgappdemo.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/Demos/app/dlgappdemo.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dlgappdemo.py 1 Sep 1999 23:33:39 -0000 1.1 --- dlgappdemo.py 10 Dec 2006 21:51:10 -0000 1.2 *************** *** 10,14 **** import win32ui import sys - import regsub class TestDialogApp(dlgappcore.DialogApp): --- 10,13 ---- *************** *** 37,41 **** self.edit.SetSel(-2) # translate \n to \n\r ! self.edit.ReplaceSel(regsub.gsub('\n','\r\n',str)) else: win32ui.OutputDebug("dlgapp - no edit control! >>\n%s\n<<\n" % str ) --- 36,40 ---- self.edit.SetSel(-2) # translate \n to \n\r ! self.edit.ReplaceSel(str.replace('\n','\r\n')) else: win32ui.OutputDebug("dlgapp - no edit control! >>\n%s\n<<\n" % str ) Index: basictimerapp.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/Demos/app/basictimerapp.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** basictimerapp.py 4 Jun 2000 06:19:32 -0000 1.2 --- basictimerapp.py 10 Dec 2006 21:51:10 -0000 1.3 *************** *** 10,14 **** import time import string - import regsub class TimerAppDialog(dlgappcore.AppDialog): --- 10,13 ---- *************** *** 38,42 **** self.doWork = win32ui.GetProfileVal(self.timerAppName, "Work", "DoDemoWork()") # replace "\n" with real \n. ! self.doWork = regsub.gsub('\\\\n','\n', self.doWork) dlgappcore.AppDialog.OnInitDialog(self) --- 37,41 ---- self.doWork = win32ui.GetProfileVal(self.timerAppName, "Work", "DoDemoWork()") # replace "\n" with real \n. ! self.doWork = self.doWork.replace('\\n','\n') dlgappcore.AppDialog.OnInitDialog(self) |
From: Roger U. <ru...@us...> - 2006-12-10 08:58:39
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3026/win32/src Modified Files: win32apimodule.cpp Log Message: Add GlobalMemoryStatus and GlobalMemoryStatusEx Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** win32apimodule.cpp 30 Nov 2006 05:56:42 -0000 1.67 --- win32apimodule.cpp 10 Dec 2006 08:58:37 -0000 1.68 *************** *** 46,49 **** --- 46,51 ---- typedef BOOL (WINAPI *SetHandleInformationfunc)(HANDLE, DWORD, DWORD); static SetHandleInformationfunc pfnSetHandleInformation=NULL; + typedef BOOL (WINAPI *GlobalMemoryStatusExfunc)(LPMEMORYSTATUSEX); + static GlobalMemoryStatusExfunc pfnGlobalMemoryStatusEx=NULL; // from secur32.dll *************** *** 5095,5098 **** --- 5097,5145 ---- } + // @pymethod dict|win32api|GlobalMemoryStatus|Returns systemwide memory usage + // @rdesc Returns a dictionary representing a MEMORYSTATUS structure + PyObject *PyGlobalMemoryStatus(PyObject *self, PyObject *args) + { + #ifdef _WIN64 + static char *fmt="{s:k,s:k,s:K,s:K,s:K,s:K,s:K,s:K}"; + #else + static char *fmt="{s:k,s:k,s:k,s:k,s:k,s:k,s:k,s:k}"; + #endif + MEMORYSTATUS ms; + GlobalMemoryStatus(&ms); + return Py_BuildValue(fmt, + "Length", ms.dwLength, + "MemoryLoad", ms.dwMemoryLoad, + "TotalPhys", ms.dwTotalPhys, + "AvailPhys", ms.dwAvailPhys, + "TotalPageFile",ms.dwTotalPageFile, + "AvailPageFile",ms.dwAvailPageFile, + "TotalVirtual", ms.dwTotalVirtual, + "AvailVirtual", ms.dwAvailVirtual); + } + + // @pymethod dict|win32api|GlobalMemoryStatusEx|Returns physical and virtual memory usage + // @rdesc Returns a dictionary representing a MEMORYSTATUSEX structure + // @comm Only available on Win2k and later. + PyObject *PyGlobalMemoryStatusEx(PyObject *self, PyObject *args) + { + CHECK_PFN(GlobalMemoryStatusEx); + static char *fmt="{s:k,s:k,s:K,s:K,s:K,s:K,s:K,s:K,s:K}"; + MEMORYSTATUSEX ms; + ms.dwLength=sizeof(ms); + if (!(*pfnGlobalMemoryStatusEx)(&ms)) + return PyWin_SetAPIError("GlobalMemoryStatusEx"); + return Py_BuildValue(fmt, + "Length", ms.dwLength, + "MemoryLoad", ms.dwMemoryLoad, + "TotalPhys", ms.ullTotalPhys, + "AvailPhys", ms.ullAvailPhys, + "TotalPageFile",ms.ullTotalPageFile, + "AvailPageFile",ms.ullAvailPageFile, + "TotalVirtual", ms.ullTotalVirtual, + "AvailVirtual", ms.ullAvailVirtual, + "AvailExtendedVirtual", ms.ullAvailExtendedVirtual); + } + /* List of functions exported by this module */ *************** *** 5202,5205 **** --- 5249,5254 ---- {"GetUserDefaultLangID",PyGetUserDefaultLangID,1}, // @pymeth GetUserDefaultLangID|Retrieves the user default language identifier. {"GetUserDefaultLCID", PyGetUserDefaultLCID,1}, // @pymeth GetUserDefaultLCID|Retrieves the user default locale identifier. + {"GlobalMemoryStatus", PyGlobalMemoryStatus, METH_NOARGS}, // @pymeth GlobalMemoryStatus|Returns systemwide memory usage + {"GlobalMemoryStatusEx", PyGlobalMemoryStatusEx, METH_NOARGS}, // @pymeth GlobalMemoryStatusEx|Returns physical and virtual memory usage {"keybd_event", Pykeybd_event, 1}, // @pymeth keybd_event|Simulate a keyboard event {"mouse_event", Pymouse_event, 1}, // @pymeth mouse_event|Simulate a mouse event *************** *** 5378,5381 **** --- 5427,5431 ---- pfnGetHandleInformation=(GetHandleInformationfunc)GetProcAddress(hmodule,"GetHandleInformation"); pfnSetHandleInformation=(SetHandleInformationfunc)GetProcAddress(hmodule,"SetHandleInformation"); + pfnGlobalMemoryStatusEx=(GlobalMemoryStatusExfunc)GetProcAddress(hmodule,"GlobalMemoryStatusEx"); } |
From: Roger U. <ru...@us...> - 2006-12-09 08:31:30
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28799/win32/src Modified Files: win32gui.i Log Message: Add some more GDI functions, autoduck fixes Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** win32gui.i 12 Jul 2006 11:26:15 -0000 1.85 --- win32gui.i 9 Dec 2006 08:31:28 -0000 1.86 *************** *** 3512,3515 **** --- 3512,3587 ---- UINT uFormat); // @pyparm int|Format||Formatting flags, combination of win32con.DT_* values + // @pyswig |LineTo|Draw a line from current position to specified point + BOOLAPI LineTo( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + int XEnd, // @pyparm int|XEnd||Horizontal position in logical units + int YEnd); // @pyparm int|YEnd||Vertical position in logical units + + // @pyswig |Ellipse|Draws a filled ellipse on a device context + BOOLAPI Ellipse( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Device context on which to draw + int LeftRect, // @pyparm int|LeftRect||Left limit of ellipse + int TopRect, // @pyparm int|TopRect||Top limit of ellipse + int RightRect, // @pyparm int|RightRect||Right limit of ellipse + int BottomRect); // @pyparm int|BottomRect||Bottom limit of ellipse + + // @pyswig |Pie|Draws a section of an ellipse cut by 2 radials + BOOLAPI Pie( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Device context on which to draw + int LeftRect, // @pyparm int|LeftRect||Left limit of ellipse + int TopRect, // @pyparm int|TopRect||Top limit of ellipse + int RightRect, // @pyparm int|RightRect||Right limit of ellipse + int BottomRect, // @pyparm int|BottomRect||Bottom limit of ellipse + int XRadial1, // @pyparm int|XRadial1||Horizontal pos of Radial1 endpoint + int YRadial1, // @pyparm int|YRadial1||Vertical pos of Radial1 endpoint + int XRadial2, // @pyparm int|XRadial2||Horizontal pos of Radial2 endpoint + int YRadial2); // @pyparm int|YRadial2||Vertical pos of Radial2 endpoint + + // @pyswig |Arc|Draws an arc defined by an ellipse and 2 radials + BOOLAPI Arc( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Device context on which to draw + int LeftRect, // @pyparm int|LeftRect||Left limit of ellipse + int TopRect, // @pyparm int|TopRect||Top limit of ellipse + int RightRect, // @pyparm int|RightRect||Right limit of ellipse + int BottomRect, // @pyparm int|BottomRect||Bottom limit of ellipse + int XStartArc, // @pyparm int|XRadial1||Horizontal pos of Radial1 endpoint + int YStartArc, // @pyparm int|YRadial1||Vertical pos of Radial1 endpoint + int XEndArc, // @pyparm int|XRadial2||Horizontal pos of Radial2 endpoint + int XEndArc); // @pyparm int|YRadial2||Vertical pos of Radial2 endpoint + + // @pyswig |ArcTo|Draws an arc defined by an ellipse and 2 radials + // @comm Draws exactly as <om win32gui.Arc>, but changes current drawing position + BOOLAPI ArcTo( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Device context on which to draw + int LeftRect, // @pyparm int|LeftRect||Left limit of ellipse + int TopRect, // @pyparm int|TopRect||Top limit of ellipse + int RightRect, // @pyparm int|RightRect||Right limit of ellipse + int BottomRect, // @pyparm int|BottomRect||Bottom limit of ellipse + int XRadial1, // @pyparm int|XRadial1||Horizontal pos of Radial1 endpoint + int YRadial1, // @pyparm int|YRadial1||Vertical pos of Radial1 endpoint + int XRadial2, // @pyparm int|XRadial2||Horizontal pos of Radial2 endpoint + int YRadial2); // @pyparm int|YRadial2||Vertical pos of Radial2 endpoint + + // @pyswig |Chord|Draws a chord defined by an ellipse and 2 radials + BOOLAPI Chord( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Device context on which to draw + int LeftRect, // @pyparm int|LeftRect||Left limit of ellipse + int TopRect, // @pyparm int|TopRect||Top limit of ellipse + int RightRect, // @pyparm int|RightRect||Right limit of ellipse + int BottomRect, // @pyparm int|BottomRect||Bottom limit of ellipse + int XRadial1, // @pyparm int|XRadial1||Horizontal pos of Radial1 endpoint + int YRadial1, // @pyparm int|YRadial1||Vertical pos of Radial1 endpoint + int XRadial2, // @pyparm int|XRadial2||Horizontal pos of Radial2 endpoint + int YRadial2); // @pyparm int|YRadial2||Vertical pos of Radial2 endpoint + + // @pyswig (int, int)|MoveToEx|Changes the current drawing position + // @rdesc Returns the previous position as (X, Y) + BOOLAPI MoveToEx( + HDC hdc, // @pyparm <o PyHANDLE>|hcl||Device context handle + int X, // @pyparm int|X||Horizontal pos in logical units + int Y, // @pyparm int|Y||Vertical pos in logical units + POINT *OUTPUT); + + %{ //@pyswig int|ExtTextOut|Writes text to a DC. *************** *** 3602,3609 **** COLORREF col); // @pyparm int|color|| ! // @pyswig |DrawEdge| ! BOOLAPI DrawEdge(HDC hdc, RECT *INPUT, UINT edge, UINT grfFlags); ! // @pyswig |FillRect| ! int FillRect(HDC hDC, RECT *INPUT, HBRUSH hbr); // @pyswig |DrawAnimatedRects| BOOLAPI DrawAnimatedRects( --- 3674,3693 ---- COLORREF col); // @pyparm int|color|| ! // @pyswig <o RECT>|DrawEdge|Draws edge(s) of a rectangle ! // @rdesc BF_ADJUST flag causes input rectange to be shrunk by size of border.. Rectangle is always returned. ! BOOLAPI DrawEdge( ! /* ??? This function can change the input rectange if BF_ADJUST is in Flags. ! Need to send it back as output also. ??? */ ! HDC hdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context ! RECT *BOTH, // @pyparm <o RECT>|rc||Rectangle whose edge(s) will be drawn ! UINT edge, // @pyparm int|edge||Combination of win32con.BDR_* flags, or one of win32con.EDGE_* flags ! UINT Flags); // @pyparm int|Flags||Combination of win32con.BF_* flags ! ! // @pyswig |FillRect|Fills a rectangular area with specified brush ! int FillRect( ! HDC hDC, // @pyparm <o PyHANDLE>|hDC||Handle to a device context ! RECT *INPUT, // @pyparm <o RECT>|rc||Rectangle to be filled ! HBRUSH hbr); // @pyparm <o PyHANDLE>|hbr||Handle to brush to be used to fill area ! // @pyswig |DrawAnimatedRects| BOOLAPI DrawAnimatedRects( *************** *** 3613,3634 **** RECT *INPUT // // @pyparm RECT|restCoords||rectangle coordinates (restored) ); ! // @pyswig |CreateSolidBrush| ! HBRUSH CreateSolidBrush(COLORREF color); ! // @pyswig |CreatePen| ! HPEN CreatePen(int fnPenStyle, int nWidth, COLORREF crColor); ! // @pyswig |GetSysColor| ! DWORD GetSysColor(int nIndex); ! // @pyswig |GetSysColorBrush| ! HBRUSH GetSysColorBrush(int nIndex); // @pyswig |InvalidateRect| BOOLAPI InvalidateRect(HWND hWnd, RECT *INPUT_NULLOK , BOOL bErase); #ifndef MS_WINCE ! // @pyswig |FrameRect| ! int FrameRect(HDC hDC, RECT *INPUT, HBRUSH hbr); #endif /* not MS_WINCE */ // @pyswig |GetUpdateRgn| int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase); ! // @pyswig |Rectangle| ! BOOLAPI Rectangle(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect); // @pyswig hdc, paintstruct|BeginPaint| --- 3697,3747 ---- RECT *INPUT // // @pyparm RECT|restCoords||rectangle coordinates (restored) ); ! ! // @pyswig <o PyHANDLE>|CreateSolidBrush|Creates a solid brush of specified color ! HBRUSH CreateSolidBrush( ! COLORREF Color); // @pyparm int|Color||RGB color value. See <om win32api.RGB>. ! ! // @pyswig <o PyHANDLE>|CreatePatternBrush|Creates a brush using a bitmap as a pattern ! HBRUSH CreatePatternBrush( ! HBITMAP hbmp); // @pyparm <o PyHANDLE>|hbmp||Handle to a bitmap ! ! // @pyswig <o PyHANDLE>|CreateHatchBrush|Creates a hatch brush with specified style and color ! HBRUSH CreateHatchBrush( ! int Style, // @pyparm int|Style||Hatch style, one of win32con.HS_* constants ! COLORREF clrref); // @pyparm int|clrref||Rgb color value. See <om win32api.RGB>. ! ! // @pyswig <o PyHANDLE>|CreatePen|Create a GDI pen ! HPEN CreatePen( ! int PenStyle, // @pyparm int|PenStyle||One of win32con.PS_* pen styles ! int Width, // @pyparm int|Width||Drawing width in pixels ! COLORREF Color); // @pyparm int|Color||RGB color value. See <om win32api.RGB>. ! ! // @pyswig int|GetSysColor|Returns the color of a window element ! DWORD GetSysColor(int Index); // @pyparm int|Index||One of win32con.COLOR_* values ! ! // @pyswig <o PyHANDLE>|GetSysColorBrush|Creates a handle to a system color brush ! HBRUSH GetSysColorBrush(int nIndex); // @pyparm int|Index||Index of a window element color (win32con.COLOR_*) ! // @pyswig |InvalidateRect| BOOLAPI InvalidateRect(HWND hWnd, RECT *INPUT_NULLOK , BOOL bErase); + #ifndef MS_WINCE ! // @pyswig |FrameRect|Draws an outline around a rectangle ! int FrameRect( ! HDC hDC, // @pyparm <o PyHANDLE>|hDC||Handle to a device context ! RECT *INPUT, // @pyparm <o RECT>|rc||Rectangle around which to draw ! HBRUSH hbr); // @pyparm <o PyHANDLE>|hbr||Handle to brush created using CreateHatchBrush, CreatePatternBrush, CreateSolidBrush, or GetStockObject #endif /* not MS_WINCE */ + // @pyswig |GetUpdateRgn| int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase); ! ! // @pyswig |Rectangle|Creates a solid rectangle using currently selected pen and brush ! BOOLAPI Rectangle( ! HDC hdc, // @pyparm <o PyHANDLE>|hdc||Handle to device context ! int nLeftRect, // @pyparm int|LeftRect||Position of left edge of rectangle ! int nTopRect, // @pyparm int|TopRect||Position of top edge of rectangle ! int nRightRect, // @pyparm int|RightRect||Posistion of right edge of rectangle ! int nBottomRect); // @pyparm int|BottomRect||Position of bottom edge of rectangle // @pyswig hdc, paintstruct|BeginPaint| *************** *** 3667,3674 **** ); ! // @pyswig |GetCursorPos|retrieves the cursor's position, in screen coordinates. BOOLAPI GetCursorPos( ! POINT *OUTPUT // @pyparm int, int|point||address of structure for cursor position ! ); // @pyswig int|GetDesktopWindow|returns the desktop window --- 3780,3786 ---- ); ! // @pyswig (int, int)|GetCursorPos|retrieves the cursor's position, in screen coordinates. BOOLAPI GetCursorPos( ! POINT *OUTPUT); // @pyswig int|GetDesktopWindow|returns the desktop window |
From: Roger U. <ru...@us...> - 2006-12-09 02:57:52
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6252/win32/Demos Modified Files: print_desktop.py Log Message: Remove dependency on win32ui Index: print_desktop.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/print_desktop.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** print_desktop.py 23 May 2005 14:03:47 -0000 1.3 --- print_desktop.py 9 Dec 2006 02:57:49 -0000 1.4 *************** *** 1,3 **** ! import win32print, pywintypes, win32con, win32gui, win32ui, win32api pname=win32print.GetDefaultPrinter() --- 1,3 ---- ! import win32print, pywintypes, win32con, win32gui, win32api pname=win32print.GetDefaultPrinter() *************** *** 17,22 **** pDC=win32gui.CreateDC(print_processor,pname,dm) ! printerwidth=win32ui.GetDeviceCaps(pDC, 110) ##PHYSICALWIDTH ! printerheight=win32ui.GetDeviceCaps(pDC, 111) ##PHYSICALHEIGHT hwnd=win32gui.GetDesktopWindow() --- 17,22 ---- pDC=win32gui.CreateDC(print_processor,pname,dm) ! printerwidth=win32print.GetDeviceCaps(pDC, win32con.PHYSICALWIDTH) ! printerheight=win32print.GetDeviceCaps(pDC, win32con.PHYSICALHEIGHT) hwnd=win32gui.GetDesktopWindow() |
From: Roger U. <ru...@us...> - 2006-12-09 02:56:38
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5879/win32/src/win32print Modified Files: win32print.cpp Log Message: Add GetDeviceCaps Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** win32print.cpp 8 Dec 2006 09:26:46 -0000 1.22 --- win32print.cpp 9 Dec 2006 02:56:36 -0000 1.23 *************** *** 2065,2068 **** --- 2065,2087 ---- } + // @pymethod int|win32print|GetDeviceCaps|Retrieves device-specific parameters and settings + // @comm Can also be used for Display DCs in addition to printer DCs + // @pyseeapi GetDeviceCaps + static PyObject *PyGetDeviceCaps(PyObject *self, PyObject *args) + { + PyObject *obdc; + DWORD index; + int ret; + HDC hdc; + if (!PyArg_ParseTuple(args, "Ok", + &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a printer or display device context + &index)) // @pyparm int|Index||The capability to return. See MSDN for valid values. + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc)) + return NULL; + ret=GetDeviceCaps(hdc, index); + return Py_BuildValue("i", ret); + } + // @pymethod (dict,...)|win32print|EnumMonitors|Lists installed printer port monitors static PyObject *PyEnumMonitors(PyObject *self, PyObject *args) *************** *** 2480,2483 **** --- 2499,2503 ---- {"ScheduleJob", PyScheduleJob, 1}, //@pymeth ScheduleJob|Schedules a spooled job to be printed {"DeviceCapabilities", PyDeviceCapabilities, 1}, //@pymeth DeviceCapabilities|Queries a printer for its capabilities + {"GetDeviceCaps", PyGetDeviceCaps, METH_VARARGS}, //@pymeth GetDeviceCaps|Retrieves device-specific parameters and settings {"EnumMonitors", PyEnumMonitors, 1}, //@pymeth EnumMonitors|Lists installed printer port monitors {"EnumPorts", PyEnumPorts, 1}, //@pymeth EnumPorts|Lists printer ports on a server |
From: Roger U. <ru...@us...> - 2006-12-08 10:48:43
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11786/win32/Lib Modified Files: win32con.py Log Message: Add some more constants Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32con.py 13 May 2006 12:01:24 -0000 1.15 --- win32con.py 8 Dec 2006 10:48:42 -0000 1.16 *************** *** 2764,2767 **** --- 2764,2781 ---- NUMRESERVED = 106 COLORRES = 108 + + PHYSICALWIDTH = 110 + PHYSICALHEIGHT = 111 + PHYSICALOFFSETX = 112 + PHYSICALOFFSETY = 113 + SCALINGFACTORX = 114 + SCALINGFACTORY = 115 + VREFRESH = 116 + DESKTOPVERTRES = 117 + DESKTOPHORZRES = 118 + BLTALIGNMENT = 119 + SHADEBLENDCAPS = 120 + COLORMGMTCAPS = 121 + DT_PLOTTER = 0 DT_RASDISPLAY = 1 *************** *** 3036,3040 **** DMBIN_LARGECAPACITY = 11 DMBIN_CASSETTE = 14 ! DMBIN_LAST = DMBIN_CASSETTE DMBIN_USER = 256 --- 3050,3055 ---- DMBIN_LARGECAPACITY = 11 DMBIN_CASSETTE = 14 ! DMBIN_FORMSOURCE = 15 ! DMBIN_LAST = DMBIN_FORMSOURCE DMBIN_USER = 256 *************** *** 3182,3185 **** --- 3197,3209 ---- DCTT_DOWNLOAD_OUTLINE = 8 + DCBA_FACEUPNONE = 0 + DCBA_FACEUPCENTER = 1 + DCBA_FACEUPLEFT = 2 + DCBA_FACEUPRIGHT = 3 + DCBA_FACEDOWNNONE = 256 + DCBA_FACEDOWNCENTER = 257 + DCBA_FACEDOWNLEFT = 258 + DCBA_FACEDOWNRIGHT = 259 + CA_NEGATIVE = 1 CA_LOG_FILTER = 2 *************** *** 3471,3474 **** --- 3495,3501 ---- CLR_INVALID = -1 + DC_BRUSH = 18 + DC_PEN = 19 + # Exception/Status codes from winuser.h and winnt.h STATUS_WAIT_0 = 0 |
From: Roger U. <ru...@us...> - 2006-12-08 09:26:48
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14729/win32/src/win32print Modified Files: win32print.cpp Log Message: Add FlushPrinter, GetDefaultPrinterW, SetDefaultPrinterW and some more constants Return printer handles as PyHANDLE subclass Stop parsing handles with 'i' and 'l' formats Use 'k' format for DWORDS Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** win32print.cpp 15 Feb 2005 16:39:04 -0000 1.21 --- win32print.cpp 8 Dec 2006 09:26:46 -0000 1.22 *************** *** 44,50 **** --- 44,89 ---- typedef BOOL (WINAPI *DeletePrinterDriverExfunc)(LPWSTR, LPWSTR, LPWSTR, DWORD, DWORD); static DeletePrinterDriverExfunc pfnDeletePrinterDriverEx=NULL; + typedef BOOL (WINAPI *FlushPrinterfunc)(HANDLE, LPVOID, DWORD, LPDWORD, DWORD); + static FlushPrinterfunc pfnFlushPrinter=NULL; + typedef BOOL (WINAPI *GetDefaultPrinterfunc)(LPWSTR, LPDWORD); + static GetDefaultPrinterfunc pfnGetDefaultPrinter=NULL; + typedef BOOL (WINAPI *SetDefaultPrinterfunc)(LPWSTR); + static SetDefaultPrinterfunc pfnSetDefaultPrinter=NULL; [...1363 lines suppressed...] + AddConstant(dict, "PORT_STATUS_TONER_LOW",PORT_STATUS_TONER_LOW); + AddConstant(dict, "PORT_STATUS_WARMING_UP",PORT_STATUS_WARMING_UP); + AddConstant(dict, "PORT_STATUS_POWER_SAVE",PORT_STATUS_POWER_SAVE); + + AddConstant(dict, "PORT_STATUS_TYPE_ERROR",PORT_STATUS_TYPE_ERROR); + AddConstant(dict, "PORT_STATUS_TYPE_WARNING",PORT_STATUS_TYPE_WARNING); + AddConstant(dict, "PORT_STATUS_TYPE_INFO",PORT_STATUS_TYPE_INFO); + HMODULE hmodule=LoadLibrary("winspool.drv"); if (hmodule!=NULL){ *************** *** 2504,2507 **** --- 2686,2692 ---- pfnGetPrinterDriverDirectory=(GetPrintProcessorDirectoryfunc)GetProcAddress(hmodule,"GetPrinterDriverDirectoryW"); pfnDeletePrinterDriverEx=(DeletePrinterDriverExfunc)GetProcAddress(hmodule,"DeletePrinterDriverExW"); + pfnFlushPrinter=(FlushPrinterfunc)GetProcAddress(hmodule, "FlushPrinter"); + pfnGetDefaultPrinter=(GetDefaultPrinterfunc)GetProcAddress(hmodule, "GetDefaultPrinterW"); + pfnSetDefaultPrinter=(SetDefaultPrinterfunc)GetProcAddress(hmodule, "SetDefaultPrinterW"); } dummy_tuple=PyTuple_New(0); |
From: Mark H. <mha...@us...> - 2006-12-04 22:52:28
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10924 Modified Files: win32win.cpp Log Message: [ 1608456 ] SetIcon() for PyCWnd Contributed by ckuhlmann Index: win32win.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** win32win.cpp 11 Jul 2006 05:18:30 -0000 1.10 --- win32win.cpp 4 Dec 2006 22:52:24 -0000 1.11 *************** *** 3052,3055 **** --- 3052,3071 ---- } + // @pymethod HICON|PyCWnd|SetIcon|Calls the underlying MFC SetIcon method. + PyObject* ui_window_set_icon(PyObject* self, PyObject *args) + { + HICON hiconPrevIcon; + BOOL bBigIcon = TRUE; + if (!PyArg_ParseTuple(args, "ii:SetIcon", &hiconPrevIcon, &bBigIcon)) + return NULL; + CWnd *pWnd = GetWndPtr(self); + if (!pWnd) + return NULL; + GUI_BGN_SAVE; + HICON hiconRetVal = pWnd->SetIcon(hiconPrevIcon, bBigIcon); + GUI_END_SAVE; + return Py_BuildValue("i", hiconRetVal); + } + /////////////////////////////////////// // *************** *** 3158,3161 **** --- 3174,3178 ---- {"SetFocus", ui_window_set_focus, 1}, // @pymeth SetFocus|Sets focus to the window. {"SetFont", ui_window_set_font, 1}, // @pymeth SetFont|Sets the window's current font to the specified font. + {"SetIcon", ui_window_set_icon, 1}, // @pymeth SetIcon | Sets the handle to a specific icon. {"SetMenu", ui_window_set_menu, 1}, // @pymeth SetMenu|Sets the menu for a window. {"SetRedraw", ui_window_set_redraw, 1}, // @pymeth SetRedraw|Sets the redraw flag for the window. *************** *** 4139,4140 **** --- 4156,4159 ---- PyCMDIChildWnd_methods, GET_PY_CTOR(PyCMDIChildWnd)); + + |
From: Roger U. <ru...@us...> - 2006-12-04 04:56:09
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20164/win32/src Modified Files: PySECURITY_DESCRIPTOR.cpp Log Message: Add allocation checks to _MakeSelfRelativeSD Index: PySECURITY_DESCRIPTOR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PySECURITY_DESCRIPTOR.cpp 4 Dec 2006 03:51:52 -0000 1.17 --- PySECURITY_DESCRIPTOR.cpp 4 Dec 2006 04:56:08 -0000 1.18 *************** *** 157,161 **** *ppsd_relative = malloc(buflen); ! if (MakeSelfRelativeSD(psd_absolute,*ppsd_relative,&buflen)) return TRUE; free(*ppsd_relative); --- 157,165 ---- *ppsd_relative = malloc(buflen); ! if (*ppsd_relative==NULL){ ! PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", buflen); ! return FALSE; ! } ! if (MakeSelfRelativeSD(psd_absolute,*ppsd_relative,&buflen)) return TRUE; free(*ppsd_relative); *************** *** 167,173 **** --- 171,182 ---- *ppsd_relative = malloc(buflen); + if (*ppsd_relative==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", buflen); + return FALSE; + } if (MakeSelfRelativeSD(psd_absolute,*ppsd_relative,&buflen)) return TRUE; free(*ppsd_relative); + *ppsd_relative=NULL; PyWin_SetAPIError("MakeSelfRelativeSD"); return FALSE; *************** *** 254,258 **** error_exit: *ppsd_absolute=NULL; ! // *Don't* use FreeAbsoluteSD aince function may exit without the sd having been constructed yet if (psd_absolute!=NULL) free(psd_absolute); --- 263,267 ---- error_exit: *ppsd_absolute=NULL; ! // *Don't* use FreeAbsoluteSD since function may exit without the sd having been constructed yet if (psd_absolute!=NULL) free(psd_absolute); |
From: Roger U. <ru...@us...> - 2006-12-04 03:51:54
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29412/win32/src Modified Files: PySECURITY_DESCRIPTOR.cpp Log Message: Add allocation error checking in _MakeAbsoluteSD, remove a couple of extraneous InitializeSecurityDescriptor calls Index: PySECURITY_DESCRIPTOR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PySECURITY_DESCRIPTOR.cpp 28 Jan 2005 08:50:20 -0000 1.16 --- PySECURITY_DESCRIPTOR.cpp 4 Dec 2006 03:51:52 -0000 1.17 *************** *** 187,195 **** DWORD ownersize = 0; DWORD groupsize = 0; psd_absolute = malloc(sdsize); ZeroMemory(psd_absolute,sdsize); - ::InitializeSecurityDescriptor(psd_absolute,SECURITY_DESCRIPTOR_REVISION); - BOOL resize = FALSE; if(MakeAbsoluteSD(psd_relative, psd_absolute, &sdsize, --- 187,198 ---- DWORD ownersize = 0; DWORD groupsize = 0; + BOOL resize = FALSE; psd_absolute = malloc(sdsize); + if (psd_absolute==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", sdsize); + goto error_exit; + } ZeroMemory(psd_absolute,sdsize); if(MakeAbsoluteSD(psd_relative, psd_absolute, &sdsize, *************** *** 203,237 **** free (psd_absolute); psd_absolute = malloc(sdsize); ! ::InitializeSecurityDescriptor(psd_absolute,SECURITY_DESCRIPTOR_REVISION); } if (daclsize > 0){ resize = TRUE; pdacl = (ACL *)malloc(daclsize); } if (saclsize > 0){ resize = TRUE; psacl = (ACL *)malloc(saclsize); } if (ownersize > 0){ resize = TRUE; powner = (SID *)malloc(ownersize); } if (groupsize > 0){ resize = TRUE; pgroup = (SID *)malloc(groupsize); } ! if (!resize){ ! FreeAbsoluteSD(psd_absolute); ! PyWin_SetAPIError("MakeAbsoluteSD"); ! return FALSE; ! } ! if(MakeAbsoluteSD(psd_relative, psd_absolute, &sdsize, ! pdacl, &daclsize, psacl, &saclsize, ! powner, &ownersize, pgroup, &groupsize)){ *ppsd_absolute = psd_absolute; return TRUE; } - FreeAbsoluteSD(psd_absolute); PyWin_SetAPIError("MakeAbsoluteSD"); return FALSE; } --- 206,268 ---- free (psd_absolute); psd_absolute = malloc(sdsize); ! if (psd_absolute==NULL){ ! PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", sdsize); ! goto error_exit; ! } ! ZeroMemory(psd_absolute,sdsize); } if (daclsize > 0){ resize = TRUE; pdacl = (ACL *)malloc(daclsize); + if (pdacl==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", daclsize); + goto error_exit; + } } if (saclsize > 0){ resize = TRUE; psacl = (ACL *)malloc(saclsize); + if (psacl==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", saclsize); + goto error_exit; + } } if (ownersize > 0){ resize = TRUE; powner = (SID *)malloc(ownersize); + if (powner==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", ownersize); + goto error_exit; + } } if (groupsize > 0){ resize = TRUE; pgroup = (SID *)malloc(groupsize); + if (pgroup==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", groupsize); + goto error_exit; + } } ! if (resize && MakeAbsoluteSD(psd_relative, psd_absolute, &sdsize, ! pdacl, &daclsize, psacl, &saclsize, ! powner, &ownersize, pgroup, &groupsize)){ *ppsd_absolute = psd_absolute; return TRUE; } PyWin_SetAPIError("MakeAbsoluteSD"); + + error_exit: + *ppsd_absolute=NULL; + // *Don't* use FreeAbsoluteSD aince function may exit without the sd having been constructed yet + if (psd_absolute!=NULL) + free(psd_absolute); + if (pdacl!=NULL) + free(pdacl); + if (psacl!=NULL) + free(psacl); + if (powner!=NULL) + free(powner); + if (pgroup!=NULL) + free(pgroup); return FALSE; } |
From: Roger U. <ru...@us...> - 2006-12-03 06:03:44
|
Update of /cvsroot/pywin32/pywin32/com/win32com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12728/com/win32com Modified Files: storagecon.py Log Message: Add more com access rights flags Index: storagecon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/storagecon.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** storagecon.py 3 Dec 2003 11:33:22 -0000 1.4 --- storagecon.py 3 Dec 2006 06:03:43 -0000 1.5 *************** *** 49,53 **** --- 49,59 ---- STG_LAYOUT_SEQUENTIAL = 0x00000000L STG_LAYOUT_INTERLEAVED = 0x00000001L + + ## access rights used with COM server ACL's COM_RIGHTS_EXECUTE = 1 + COM_RIGHTS_EXECUTE_LOCAL = 2 + COM_RIGHTS_EXECUTE_REMOTE = 4 + COM_RIGHTS_ACTIVATE_LOCAL = 8 + COM_RIGHTS_ACTIVATE_REMOTE = 16 STGFMT_DOCUMENT = 0 |
From: Roger U. <ru...@us...> - 2006-12-02 15:24:14
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19101/win32/src Modified Files: win32security.i Log Message: Add DuplicateTokenEx, and some autoduck fixes Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** win32security.i 28 Sep 2006 02:27:27 -0000 1.34 --- win32security.i 2 Dec 2006 15:24:11 -0000 1.35 *************** *** 684,691 **** // Patch up any kwarg functions - SWIG doesn't like them. for (PyMethodDef *pmd = win32securityMethods;pmd->ml_name;pmd++) ! if (strcmp(pmd->ml_name, "DsGetDcName")==0) { pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; ! break; // only 1 name at the moment. ! } %} --- 684,691 ---- // Patch up any kwarg functions - SWIG doesn't like them. for (PyMethodDef *pmd = win32securityMethods;pmd->ml_name;pmd++) ! if ((strcmp(pmd->ml_name, "DsGetDcName")==0) || ! (strcmp(pmd->ml_name, "DuplicateTokenEx")==0)){ pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; ! } %} *************** *** 1684,1693 **** %{ ! // @pyswig <o PyHandle>|SetThreadToken|Assigns an impersonation token to a thread. The function // can also cause a thread to stop using an impersonation token. static PyObject *PySetThreadToken(PyObject *self, PyObject *args) { PyObject *obThread, *obToken; ! if (!PyArg_ParseTuple(args, "OO", &obThread, &obToken)) return NULL; HANDLE *phThread; --- 1684,1695 ---- %{ ! // @pyswig |SetThreadToken|Assigns an impersonation token to a thread. The function // can also cause a thread to stop using an impersonation token. static PyObject *PySetThreadToken(PyObject *self, PyObject *args) { PyObject *obThread, *obToken; ! if (!PyArg_ParseTuple(args, "OO", ! &obThread, // @pyparm <o PyHANDLE>|Thread||Handle to a thread. Use None to indicate calling thread. ! &obToken)) // @pyparm <o PyHANDLE>|Token||Handle to an impersonation token. Use None to end impersonation. return NULL; HANDLE *phThread; *************** *** 2822,2826 **** ); ! // @pyswig |DuplicateToken|Creates a copy of an access token with specified impersonation level // @pyparm <o PyHANDLE>|ExistingTokenHandle||Handle to an access token (see <om win32security.LogonUser>,<om win32security.OpenProcessToken>) // @pyparm int|ImpersonationLevel||A value from SECURITY_IMPERSONATION_LEVEL enum --- 2824,2828 ---- ); ! // @pyswig <o PyHANDLE>|DuplicateToken|Creates a copy of an access token with specified impersonation level // @pyparm <o PyHANDLE>|ExistingTokenHandle||Handle to an access token (see <om win32security.LogonUser>,<om win32security.OpenProcessToken>) // @pyparm int|ImpersonationLevel||A value from SECURITY_IMPERSONATION_LEVEL enum *************** *** 2831,2834 **** --- 2833,2868 ---- ); + // @pyswig <o PyHANDLE>|DuplicateTokenEx|Extended version of DuplicateToken. + // @comm Accepts keyword arguments + %native(DuplicateTokenEx) pfnPyDuplicateTokenEx; + %{ + static PyObject *PyDuplicateTokenEx(PyObject *self, PyObject *args, PyObject *kwargs) + { + static char *keywords[]={"ExistingToken","ImpersonationLevel","DesiredAccess","TokenType","TokenAttributes", NULL}; + HANDLE htoken, hnewtoken; + PSECURITY_ATTRIBUTES psa; + SECURITY_IMPERSONATION_LEVEL lvl; + DWORD access; + TOKEN_TYPE tokentype; + PyObject *obtoken, *obsa=Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Okkk|O:DuplicateTokenEx", keywords, + &obtoken, // @pyparm <o PyHANDLE>|ExistingToken||Logon token opened with TOKEN_DUPLICATE access + &lvl, // @pyparm int|ImpersonationLevel||One of win32security.Security* values + &access, // @pyparm int|DesiredAccess||Type of access required for the handle, combination of win32security.TOKEN_* flags + &tokentype, // @pyparm int|TokenType||Type of token to be created, TokenPrimary or TokenImpersonation + &obsa)) // @pyparm <o PySECURITY_ATTRIBUTES>|TokenAttributes|None|Specifies security and inheritance for the new handle. None results in default DACL and no inheritance, + return NULL; + if (!PyWinObject_AsHANDLE(obtoken, &htoken, FALSE)) + return NULL; + if (!PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)) + return NULL; + if (!DuplicateTokenEx(htoken, access, psa, lvl, tokentype, &hnewtoken)) + return PyWin_SetAPIError("DuplicateTokenEx"); + return PyWinObject_FromHANDLE(hnewtoken); + } + PyCFunction pfnPyDuplicateTokenEx=(PyCFunction)PyDuplicateTokenEx; + %} + // @pyswig bool|CheckTokenMembership|Checks if a SID is enabled in a token %native(CheckTokenMembership) PyCheckTokenMembership; |
From: Roger U. <ru...@us...> - 2006-11-30 07:05:26
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31267/win32/Demos Added Files: RegRestoreKey.py Log Message: Show usage of RegSaveKeyEx and RegRestoreKey --- NEW FILE: RegRestoreKey.py --- import win32api, win32security import win32con, ntsecuritycon, winnt import os temp_dir=win32api.GetTempPath() fname=win32api.GetTempFileName(temp_dir,'rsk')[0] print fname ## file can't exist os.remove(fname) ## enable backup and restore privs required_privs = ((win32security.LookupPrivilegeValue('',ntsecuritycon.SE_BACKUP_NAME),win32con.SE_PRIVILEGE_ENABLED), (win32security.LookupPrivilegeValue('',ntsecuritycon.SE_RESTORE_NAME),win32con.SE_PRIVILEGE_ENABLED) ) ph = win32api.GetCurrentProcess() th = win32security.OpenProcessToken(ph, win32con.TOKEN_READ|win32con.TOKEN_ADJUST_PRIVILEGES) adjusted_privs=win32security.AdjustTokenPrivileges(th,0,required_privs) try: sa=win32security.SECURITY_ATTRIBUTES() my_sid = win32security.GetTokenInformation(th,ntsecuritycon.TokenUser)[0] sa.SECURITY_DESCRIPTOR.SetSecurityDescriptorOwner(my_sid,0) k, disp=win32api.RegCreateKeyEx(win32con.HKEY_CURRENT_USER, 'Python test key', SecurityAttributes=sa, samDesired=win32con.KEY_ALL_ACCESS, Class='some class', Options=0) win32api.RegSetValue(k, None, win32con.REG_SZ, 'Default value for python test key') subk, disp=win32api.RegCreateKeyEx(k, 'python test subkey', SecurityAttributes=sa, samDesired=win32con.KEY_ALL_ACCESS, Class='some other class', Options=0) win32api.RegSetValue(subk, None, win32con.REG_SZ, 'Default value for subkey') win32api.RegSaveKeyEx(k, fname, Flags=winnt.REG_STANDARD_FORMAT, SecurityAttributes=sa) restored_key, disp=win32api.RegCreateKeyEx(win32con.HKEY_CURRENT_USER, 'Python test key(restored)', SecurityAttributes=sa, samDesired=win32con.KEY_ALL_ACCESS, Class='restored class', Options=0) win32api.RegRestoreKey(restored_key, fname) finally: win32security.AdjustTokenPrivileges(th, 0, adjusted_privs) |
From: Roger U. <ru...@us...> - 2006-11-30 05:56:43
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6127/win32/src Modified Files: win32apimodule.cpp Log Message: Add RegSaveKeyEx and RegRestoreKey Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** win32apimodule.cpp 29 Nov 2006 03:52:42 -0000 1.66 --- win32apimodule.cpp 30 Nov 2006 05:56:42 -0000 1.67 *************** *** 52,55 **** --- 52,61 ---- static GetUserNameExfunc pfnGetComputerObjectName=NULL; + // from Advapi32.dll + typedef LONG (WINAPI *RegRestoreKeyfunc)(HKEY,LPCWSTR,DWORD); + static RegRestoreKeyfunc pfnRegRestoreKey=NULL; + typedef LONG (WINAPI *RegSaveKeyExfunc)(HKEY,LPCWSTR,LPSECURITY_ATTRIBUTES,DWORD); + static RegSaveKeyExfunc pfnRegSaveKeyEx=NULL; + /* error helper */ *************** *** 3277,3280 **** --- 3283,3317 ---- + // @pymethod |win32api|RegRestoreKey|Restores a key and subkeys from a saved registry file + // @pyseeapi RegRestoreKey + // @comm Implemented only as Unicode (RegRestoreKeyW). Accepts keyword arguments. + // @comm Requires SeBackupPrivilege and SeRestorePrivilege + static PyObject *PyRegRestoreKey(PyObject *self, PyObject *args, PyObject *kwargs) + { + static char *keywords[]={"Key","File","Flags",NULL}; + CHECK_PFN(RegRestoreKey); + HKEY hKey; + DWORD flags=0; + PyObject *obKey, *obfilename, *ret=NULL; + WCHAR *filename=NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|k:RegRestoreKey", keywords, + &obKey, // @pyparm <o PyHKEY>|Key||Handle to registry key to be restored. Can also be one of win32con.HKEY_* values. + &obfilename, // @pyparm <o PyUnicode>|File||File from which to restore registry data + &flags)) // @pyparm int|Flags|0|One of REG_FORCE_RESTORE,REG_NO_LAZY_FLUSH,REG_REFRESH_HIVE,REG_WHOLE_HIVE_VOLATILE (from winnt) + return NULL; + if (PyWinObject_AsHKEY(obKey, &hKey) + &&PyWinObject_AsWCHAR(obfilename, &filename, FALSE)){ + LONG rc=(*pfnRegRestoreKey)(hKey, filename, flags); + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegRestoreKey", rc); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PyWinObject_FreeWCHAR(filename); + return ret; + } // @pymethod |win32api|RegSaveKey|The RegSaveKey method saves the specified key, and all its subkeys to the specified file. *************** *** 3310,3313 **** --- 3347,3386 ---- // <nl>The caller of this method must possess the SeBackupPrivilege security privilege. } + + // @pymethod |win32api|RegSaveKeyEx|Extended version of RegSaveKey + // @pyseeapi RegSaveKeyEx + // @comm Implemented only as Unicode (RegSaveKeyExW). Accepts keyword arguments. + // @comm SE_BACKUP_NAME privilege must be enabled. + static PyObject *PyRegSaveKeyEx(PyObject *self, PyObject *args, PyObject *kwargs) + { + static char *keywords[]={"Key","File","SecurityAttributes","Flags",NULL}; + CHECK_PFN(RegSaveKeyEx); + HKEY hKey; + DWORD flags=REG_LATEST_FORMAT; + PyObject *obKey, *obfilename, *obsa=Py_None, *ret=NULL; + PSECURITY_ATTRIBUTES psa; + WCHAR *filename=NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|Ok:RegSaveKeyEx", keywords, + &obKey, // @pyparm <o PyHKEY>|Key||Handle to a registry key or one of HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER + &obfilename, // @pyparm <o PyUnicode>|File||Name of file in which to save data. File must not already exist. + &obsa, // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Specifies security for the file to be created + &flags)) // @pyparm int|Flags|REG_LATEST_FORMAT|One of REG_STANDARD_FORMAT,REG_LATEST_FORMAT,REG_NO_COMPRESSION (from winnt.py) + return NULL; + if (PyWinObject_AsHKEY(obKey, &hKey) + &&PyWinObject_AsWCHAR(obfilename, &filename, FALSE) + &&PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)){ + LONG rc=(*pfnRegSaveKeyEx)(hKey, filename, psa, flags); + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegSaveKeyEx", rc); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PyWinObject_FreeWCHAR(filename); + return ret; + } + // @pymethod |win32api|RegSetValue|Associates a value with a specified key. Currently, only strings are supported. static PyObject * *************** *** 5169,5173 **** --- 5242,5248 ---- {"RegQueryInfoKey", PyRegQueryInfoKey, 1}, // @pymeth RegQueryInfoKey|Returns information about the specified key. {"RegQueryInfoKeyW", PyRegQueryInfoKeyW, 1}, // @pymeth RegQueryInfoKeyW|Returns information about an open registry key + {"RegRestoreKey", (PyCFunction)PyRegRestoreKey, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegRestoreKey|Restores a key and subkeys from a saved registry file {"RegSaveKey", PyRegSaveKey, 1}, // @pymeth RegSaveKey|Saves the specified key, and all its subkeys to the specified file. + {"RegSaveKeyEx", (PyCFunction)PyRegSaveKeyEx, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegSaveKeyEx|Extended version of RegSaveKey {"RegSetKeySecurity", PyRegSetKeySecurity, 1}, // @pymeth RegSetKeySecurity|Sets the security on the specified registry key. {"RegSetValue", PyRegSetValue, 1}, // @pymeth RegSetValue|Associates a value with a specified key. Currently, only strings are supported. *************** *** 5318,5320 **** --- 5393,5404 ---- pfnEnumDisplaySettingsEx=(EnumDisplaySettingsExfunc)GetProcAddress(hmodule,"EnumDisplaySettingsExA"); } + + hmodule = GetModuleHandle("Advapi32.dll"); + if (hmodule==NULL) + hmodule=LoadLibrary("Advapi32.dll"); + if (hmodule!=NULL){ + pfnRegRestoreKey=(RegRestoreKeyfunc)GetProcAddress(hmodule, "RegRestoreKeyW"); + pfnRegSaveKeyEx=(RegSaveKeyExfunc)GetProcAddress(hmodule, "RegSaveKeyExW"); + } + } |
From: Roger U. <ru...@us...> - 2006-11-30 05:24:58
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26723/win32/Lib Modified Files: winnt.py Log Message: Add some extra constants for registry functions Index: winnt.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/winnt.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** winnt.py 14 Nov 2005 07:28:10 -0000 1.3 --- winnt.py 30 Nov 2006 05:24:56 -0000 1.4 *************** *** 963,971 **** REG_OPTION_BACKUP_RESTORE |\ REG_OPTION_OPEN_LINK) ! REG_CREATED_NEW_KEY = (1) ! REG_OPENED_EXISTING_KEY = (2) ! REG_WHOLE_HIVE_VOLATILE = (1) ! REG_REFRESH_HIVE = (2) ! REG_NO_LAZY_FLUSH = (4) REG_NOTIFY_CHANGE_NAME = (1) REG_NOTIFY_CHANGE_ATTRIBUTES = (2) --- 963,982 ---- REG_OPTION_BACKUP_RESTORE |\ REG_OPTION_OPEN_LINK) ! ! ## dispositions returned from RegCreateKeyEx ! REG_CREATED_NEW_KEY = 1 ! REG_OPENED_EXISTING_KEY = 2 ! ! ## flags used with RegSaveKeyEx ! REG_STANDARD_FORMAT = 1 ! REG_LATEST_FORMAT = 2 ! REG_NO_COMPRESSION = 4 ! ! ## flags used with RegRestoreKey ! REG_WHOLE_HIVE_VOLATILE = 1 ! REG_REFRESH_HIVE = 2 ! REG_NO_LAZY_FLUSH = 4 ! REG_FORCE_RESTORE = 8 ! REG_NOTIFY_CHANGE_NAME = (1) REG_NOTIFY_CHANGE_ATTRIBUTES = (2) |
From: Roger U. <ru...@us...> - 2006-11-29 03:52:44
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32156/win32/src Modified Files: win32apimodule.cpp Log Message: Add RegCreateKeyEx, RegQueryInfoKeyW, RegEnumKeyExW. Support Class name in RegEnumKeyEx Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** win32apimodule.cpp 1 Nov 2006 16:26:34 -0000 1.65 --- win32apimodule.cpp 29 Nov 2006 03:52:42 -0000 1.66 *************** *** 2453,2456 **** --- 2453,2498 ---- // If the function fails, an exception is raised. } + + // @pymethod <o PyHKEY>, int|win32api|RegCreateKeyEx|Extended version of RegCreateKey + // @rdesc Returns registry handle and flag indicating if key was opened or created (REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY) + // @pyseeapi RegCreateKeyEx + // @comm Implemented only as Unicode (RegCreateKeyExW). Accepts keyword arguments. + static PyObject *PyRegCreateKeyEx(PyObject *self, PyObject *args, PyObject *kwargs) + { + static char *keywords[]={"Key","SubKey","samDesired","Class","Options","SecurityAttributes", NULL}; + HKEY hKey; + PyObject *obKey, *obsubKey, *obclass=Py_None, *obsa=Py_None, *ret=NULL; + WCHAR *subKey=NULL, *class_name=NULL; + PSECURITY_ATTRIBUTES psa; + DWORD access, disp, options=REG_OPTION_NON_VOLATILE, reserved=NULL; + HKEY retKey; + long rc; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOk|OkO:RegCreateKeyEx", keywords, + &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values + &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to open or create. + &access, // @pyparm int|samDesired||Access allowed to handle, combination of win32con.KEY_* constants. Can also contain + // standard access rights such as DELETE, WRITE_OWNER, etc. + &obclass, // @pyparm <o PyUnicode>|Class|None|Name of registry key class + &options, // @pyparm int|Options|REG_OPTION_NON_VOLATILE|One of the winnt.REG_OPTION_* values + &obsa)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Specifies security for key and handle inheritance + return NULL; + if (PyWinObject_AsHKEY(obKey, &hKey) + &&PyWinObject_AsWCHAR(obsubKey, &subKey, TRUE) + &&PyWinObject_AsWCHAR(obclass, &class_name, TRUE) + &&PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)){ + rc=RegCreateKeyExW(hKey, subKey, reserved, class_name, options, + access, psa, &retKey, &disp); + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegCreateKeyEx", rc); + else + ret=Py_BuildValue("Nk", PyWinObject_FromHKEY(retKey), disp); + } + + PyWinObject_FreeWCHAR(subKey); + PyWinObject_FreeWCHAR(class_name); + return ret; + } + // @pymethod |win32api|RegDeleteKey|Deletes the specified key. This method can not delete keys with subkeys. static PyObject * *************** *** 2531,2546 **** } ! // @pymethod <o PyTuple>|win32api|RegEnumKeyEx|Returns list of subkeys, info is (name, reserved, class, last write time) - class currently not defined, will always be None, reserved always 0 static PyObject * PyRegEnumKeyEx( PyObject *self, PyObject *args ) { ! PyObject *obreghandle=NULL, *obretitem=NULL, *obtimestamp=NULL; HKEY reghandle; FILETIME timestamp; long err; ! char *key_name; ! DWORD key_len=0, max_len=0, key_ind=0, nbr_keys=0; ! PyObject *ret=NULL; ! // @pyparm <o PyHKEY>/int|key||An already open key, or any one of the following win32con constants:<nl>HKEY_CLASSES_ROOT<nl>HKEY_CURRENT_USER<nl>HKEY_LOCAL_MACHINE<nl>HKEY_USERS. if (!PyArg_ParseTuple(args, "O:RegEnumKeyEx", &obreghandle)) return NULL; --- 2573,2591 ---- } ! // @pymethod tuple|win32api|RegEnumKeyEx|Lists subkeys of a registry key ! // @rdesc Returns subkeys as tuples of (name, reserved, class, last write time). Reserved will always be 0. static PyObject * PyRegEnumKeyEx( PyObject *self, PyObject *args ) { ! PyObject *obreghandle=NULL, *obretitem; HKEY reghandle; FILETIME timestamp; long err; ! char *key_name=NULL, *class_name=NULL; ! DWORD key_len, max_key_len, key_ind=0, nbr_keys=0; ! DWORD class_len, max_class_len; ! PyObject *ret=NULL; ! ! // @pyparm <o PyHKEY>/int|Key||An already open key, or any one of the following win32con constants:<nl>HKEY_CLASSES_ROOT<nl>HKEY_CURRENT_USER<nl>HKEY_LOCAL_MACHINE<nl>HKEY_USERS. if (!PyArg_ParseTuple(args, "O:RegEnumKeyEx", &obreghandle)) return NULL; *************** *** 2548,2577 **** return NULL; ! err=RegQueryInfoKey(reghandle,NULL,NULL,NULL, &nbr_keys, &max_len, NULL,NULL,NULL,NULL,NULL,NULL); if (err!=ERROR_SUCCESS) return ReturnAPIError("RegEnumKeyEx:RegQueryInfoKey",err); ! max_len++; // trailing NULL not included ! key_name=(char *)malloc(max_len); if (key_name==NULL){ ! PyErr_SetString(PyExc_MemoryError, "RegEnumKeyEx: SOM"); ! return NULL; } ret=PyTuple_New(nbr_keys); ! for (key_ind=0;key_ind<nbr_keys;key_ind++){ ! key_len=max_len; ! err=RegEnumKeyEx(reghandle, key_ind, key_name, &key_len, NULL, NULL, NULL, ×tamp); ! if (err!=ERROR_SUCCESS){ ! Py_DECREF(ret); ! ret=NULL; ! PyWin_SetAPIError("RegEnumKeyEx",err); ! break; } ! obtimestamp=PyWinObject_FromFILETIME(timestamp); ! obretitem=Py_BuildValue("s#iOO", key_name, key_len, 0, Py_None, obtimestamp); ! Py_DECREF(obtimestamp); ! PyTuple_SET_ITEM(ret, key_ind, obretitem); } ! free(key_name); return ret; } --- 2593,2710 ---- return NULL; ! err=RegQueryInfoKey(reghandle,NULL,NULL,NULL, &nbr_keys, &max_key_len, &max_class_len, NULL,NULL,NULL,NULL,NULL); if (err!=ERROR_SUCCESS) return ReturnAPIError("RegEnumKeyEx:RegQueryInfoKey",err); ! max_key_len++; // trailing NULL not included ! key_name=(char *)malloc(max_key_len); if (key_name==NULL){ ! PyErr_Format(PyExc_MemoryError, "RegEnumKeyEx: Unable to allocate %d bytes", max_key_len); ! goto cleanup; ! } ! max_class_len++; ! class_name=(char *)malloc(max_class_len); ! if (class_name==NULL){ ! PyErr_Format(PyExc_MemoryError, "RegEnumKeyEx: Unable to allocate %d bytes", max_class_len); ! goto cleanup; } ret=PyTuple_New(nbr_keys); ! if (ret!=NULL) ! for (key_ind=0;key_ind<nbr_keys;key_ind++){ ! key_len=max_key_len; ! class_len=max_class_len; ! err=RegEnumKeyEx(reghandle, key_ind, key_name, &key_len, NULL, class_name, &class_len, ×tamp); ! if (err!=ERROR_SUCCESS){ ! Py_DECREF(ret); ! ret=NULL; ! PyWin_SetAPIError("RegEnumKeyEx",err); ! break; ! } ! obretitem=Py_BuildValue("NiNN", ! PyString_FromStringAndSize(key_name, key_len), ! 0, ! PyString_FromStringAndSize(class_name, class_len), ! PyWinObject_FromFILETIME(timestamp)); ! if (obretitem==NULL){ ! Py_DECREF(ret); ! ret=NULL; ! break; ! } ! PyTuple_SET_ITEM(ret, key_ind, obretitem); } ! ! cleanup: ! if (key_name) ! free(key_name); ! if (class_name) ! free(class_name); ! return ret; ! } ! ! // @pymethod tuple|win32api|RegEnumKeyExW|Unicode version of RegEnumKeyEx ! // @rdesc Returns subkeys as tuples of (name, reserved, class, last write time). Reserved will always be 0. ! static PyObject *PyRegEnumKeyExW(PyObject *self, PyObject *args) ! { ! PyObject *obreghandle=NULL, *obretitem; ! HKEY reghandle; ! FILETIME timestamp; ! long err; ! WCHAR *key_name=NULL, *class_name=NULL; ! DWORD key_len, max_key_len, key_ind, nbr_keys; ! DWORD class_len, max_class_len; ! PyObject *ret=NULL; ! ! // @pyparm <o PyHKEY>|Key||Registry handle opened with KEY_ENUMERATE_SUB_KEYS, or one of win32con.HKEY_* constants ! if (!PyArg_ParseTuple(args, "O:RegEnumKeyExW", &obreghandle)) ! return NULL; ! if (!PyWinObject_AsHKEY(obreghandle, ®handle)) ! return NULL; ! ! err=RegQueryInfoKey(reghandle,NULL,NULL,NULL, &nbr_keys, &max_key_len, &max_class_len, NULL,NULL,NULL,NULL,NULL); ! if (err!=ERROR_SUCCESS) ! return ReturnAPIError("RegEnumKeyExW:RegQueryInfoKey",err); ! max_key_len++; // trailing NULL not included ! key_name=(WCHAR *)malloc(max_key_len * sizeof(WCHAR)); ! if (key_name==NULL){ ! PyErr_Format(PyExc_MemoryError, "RegEnumKeyExW: Unable to allocate %d bytes", max_key_len); ! goto cleanup; } ! max_class_len++; ! class_name=(WCHAR *)malloc(max_class_len * sizeof(WCHAR)); ! if (class_name==NULL){ ! PyErr_Format(PyExc_MemoryError, "RegEnumKeyExW: Unable to allocate %d bytes", max_class_len); ! goto cleanup; ! } ! ! ret=PyTuple_New(nbr_keys); ! if (ret!=NULL) ! for (key_ind=0;key_ind<nbr_keys;key_ind++){ ! key_len=max_key_len; ! class_len=max_class_len; ! err=RegEnumKeyExW(reghandle, key_ind, key_name, &key_len, NULL, class_name, &class_len, ×tamp); ! if (err!=ERROR_SUCCESS){ ! Py_DECREF(ret); ! ret=NULL; ! PyWin_SetAPIError("RegEnumKeyExW",err); ! break; ! } ! obretitem=Py_BuildValue("NiNN", ! PyWinObject_FromWCHAR(key_name, key_len), ! 0, ! PyWinObject_FromWCHAR(class_name, class_len), ! PyWinObject_FromFILETIME(timestamp)); ! if (obretitem==NULL){ ! Py_DECREF(ret); ! ret=NULL; ! break; ! } ! PyTuple_SET_ITEM(ret, key_ind, obretitem); ! } ! ! cleanup: ! if (key_name) ! free(key_name); ! if (class_name) ! free(class_name); return ret; } *************** *** 3018,3021 **** --- 3151,3211 ---- } + // @pymethod dict|win32api|RegQueryInfoKeyW|Returns information about an open registry key + // @pyseeapi RegQueryInfoKeyW + static PyObject *PyRegQueryInfoKeyW(PyObject *self, PyObject *args) + { + HKEY hKey; + PyObject *obKey, *ret=NULL; + long rc; + DWORD classlen=256, SubKeys, MaxSubKeyLen, MaxClassLen, Values, MaxValueNameLen, MaxValueLen, cbSecurityDescriptor; + FILETIME ft; + WCHAR *classname=NULL; + + // @pyparm <o PyHKEY>|Key||Handle to a registry key, or one of win32con.HKEY_* constants + if (!PyArg_ParseTuple(args, "O:RegQueryInfoKeyW", &obKey)) + return NULL; + if (!PyWinObject_AsHKEY(obKey, &hKey)) + return NULL; + + #ifdef Py_DEBUG + // make sure we always do the reallocation in debug mode + classlen=1; + #endif + classname=(WCHAR *)malloc(classlen*sizeof(WCHAR)); + if (classname==NULL) + return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", classlen*sizeof(WCHAR)); + + rc=RegQueryInfoKeyW(hKey, classname, &classlen, NULL, &SubKeys, &MaxSubKeyLen, + &MaxClassLen, &Values, &MaxValueNameLen, &MaxValueLen, &cbSecurityDescriptor, &ft); + // MSDN says it should return ERROR_MORE_DATA, but I get ERROR_INSUFFICIENT_BUFFER on WinXP + if ((rc==ERROR_INSUFFICIENT_BUFFER) || (rc==ERROR_MORE_DATA)){ + free(classname); + classlen++; // returned value doesn't include null terminator + classname=(WCHAR *)malloc(classlen*sizeof(WCHAR)); + if (classname==NULL) + return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", classlen*sizeof(WCHAR)); + rc=RegQueryInfoKeyW(hKey, classname, &classlen, NULL, &SubKeys, &MaxSubKeyLen, + &MaxClassLen, &Values, &MaxValueNameLen, &MaxValueLen, &cbSecurityDescriptor, &ft); + } + + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegQueryInfoKeyW", rc); + else + ret = Py_BuildValue("{s:N,s:O,s:k,s:k,s:k,s:k,s:k,s:k,s:k,s:N}", + "Class", PyWinObject_FromWCHAR(classname, classlen), + "Reserved", Py_None, + "SubKeys", SubKeys, + "MaxSubKeyLen", MaxSubKeyLen, + "MaxClassLen", MaxClassLen, + "Values", Values, + "MaxValueNameLen", MaxValueNameLen, + "MaxValueLen", MaxValueLen, + "cbSecurityDescriptor", cbSecurityDescriptor, + "LastWriteTime", PyWinObject_FromFILETIME(ft)); + + free(classname); + return ret; + } + // @pymethod string|win32api|RegQueryValue|The RegQueryValue method retrieves the value associated with // the unnamed value for a specified key in the registry. *************** *** 3274,3278 **** if (!PyWinObject_AsHKEY(obKey, &hKey)) return NULL; ! // @pyseeapi PyRegGetKeySecurity DWORD cb = 0; DWORD rc; --- 3464,3468 ---- if (!PyWinObject_AsHKEY(obKey, &hKey)) return NULL; ! // @pyseeapi RegGetKeySecurity DWORD cb = 0; DWORD rc; *************** *** 4963,4970 **** {"RegConnectRegistry", PyRegConnectRegistry, 1}, // @pymeth RegConnectRegistry|Establishes a connection to a predefined registry handle on another computer. {"RegCreateKey", PyRegCreateKey, 1}, // @pymeth RegCreateKey|Creates the specified key, or opens the key if it already exists. {"RegDeleteKey", PyRegDeleteKey, 1}, // @pymeth RegDeleteKey|Deletes the specified key. {"RegDeleteValue", PyRegDeleteValue, 1}, // @pymeth RegDeleteValue|Removes a named value from the specified registry key. {"RegEnumKey", PyRegEnumKey, 1}, // @pymeth RegEnumKey|Enumerates subkeys of the specified open registry key. ! {"RegEnumKeyEx", PyRegEnumKeyEx, 1}, // @pymeth RegEnumKey|Enumerates subkeys of the specified open registry key. {"RegEnumValue", PyRegEnumValue, 1}, // @pymeth RegEnumValue|Enumerates values of the specified open registry key. {"RegFlushKey", PyRegFlushKey, 1}, // @pymeth RegFlushKey|Writes all the attributes of the specified key to the registry. --- 5153,5162 ---- {"RegConnectRegistry", PyRegConnectRegistry, 1}, // @pymeth RegConnectRegistry|Establishes a connection to a predefined registry handle on another computer. {"RegCreateKey", PyRegCreateKey, 1}, // @pymeth RegCreateKey|Creates the specified key, or opens the key if it already exists. + {"RegCreateKeyEx", (PyCFunction)PyRegCreateKeyEx, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCreateKeyEx|Extended version of RegCreateKey {"RegDeleteKey", PyRegDeleteKey, 1}, // @pymeth RegDeleteKey|Deletes the specified key. {"RegDeleteValue", PyRegDeleteValue, 1}, // @pymeth RegDeleteValue|Removes a named value from the specified registry key. {"RegEnumKey", PyRegEnumKey, 1}, // @pymeth RegEnumKey|Enumerates subkeys of the specified open registry key. ! {"RegEnumKeyEx", PyRegEnumKeyEx, 1}, // @pymeth RegEnumKeyEx|Enumerates subkeys of the specified open registry key. ! {"RegEnumKeyExW", PyRegEnumKeyExW, 1}, // @pymeth RegEnumKeyExW|Unicode version of RegEnumKeyEx {"RegEnumValue", PyRegEnumValue, 1}, // @pymeth RegEnumValue|Enumerates values of the specified open registry key. {"RegFlushKey", PyRegFlushKey, 1}, // @pymeth RegFlushKey|Writes all the attributes of the specified key to the registry. *************** *** 4974,4979 **** {"RegOpenKeyEx", PyRegOpenKey, 1}, // @pymeth RegOpenKeyEx|Opens the specified key. {"RegQueryValue", PyRegQueryValue, 1}, // @pymeth RegQueryValue|Retrieves the value associated with the unnamed value for a specified key in the registry. ! {"RegQueryValueEx", PyRegQueryValueEx, 1}, // @pymeth RegQueryValueEx|Retrieves the type and data for a specified value name associated with an open registry key. ! {"RegQueryInfoKey", PyRegQueryInfoKey, 1}, // @pymeth RegQueryInfoKey|Returns information about the specified key. {"RegSaveKey", PyRegSaveKey, 1}, // @pymeth RegSaveKey|Saves the specified key, and all its subkeys to the specified file. {"RegSetKeySecurity", PyRegSetKeySecurity, 1}, // @pymeth RegSetKeySecurity|Sets the security on the specified registry key. --- 5166,5172 ---- {"RegOpenKeyEx", PyRegOpenKey, 1}, // @pymeth RegOpenKeyEx|Opens the specified key. {"RegQueryValue", PyRegQueryValue, 1}, // @pymeth RegQueryValue|Retrieves the value associated with the unnamed value for a specified key in the registry. ! {"RegQueryValueEx", PyRegQueryValueEx, 1}, // @pymeth RegQueryValueEx|Retrieves the type and data for a specified value name associated with an open registry key. ! {"RegQueryInfoKey", PyRegQueryInfoKey, 1}, // @pymeth RegQueryInfoKey|Returns information about the specified key. ! {"RegQueryInfoKeyW", PyRegQueryInfoKeyW, 1}, // @pymeth RegQueryInfoKeyW|Returns information about an open registry key {"RegSaveKey", PyRegSaveKey, 1}, // @pymeth RegSaveKey|Saves the specified key, and all its subkeys to the specified file. {"RegSetKeySecurity", PyRegSetKeySecurity, 1}, // @pymeth RegSetKeySecurity|Sets the security on the specified registry key. |
From: Mark H. <mha...@us...> - 2006-11-21 06:56:06
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3216 Modified Files: testvb.py Log Message: Test assigning and fetching a buffer object to a Variant property Index: testvb.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testvb.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** testvb.py 7 Sep 2004 02:09:20 -0000 1.19 --- testvb.py 21 Nov 2006 06:56:04 -0000 1.20 *************** *** 85,88 **** --- 85,91 ---- if vbtest.VariantProperty != 10: raise error, "Could not set the variant integer property correctly." + vbtest.VariantProperty = buffer('raw\0data') + if vbtest.VariantProperty != buffer('raw\0data'): + raise error, "Could not set the variant buffer property correctly." vbtest.StringProperty = "Hello from Python" if vbtest.StringProperty != "Hello from Python": |
From: Mark H. <mha...@us...> - 2006-11-20 22:21:55
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12889/test Modified Files: test_win32file.py Log Message: win32file.ReadDirectoryChanges ignored 1 char filenames. >From Niki Spahiev. Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_win32file.py 22 Sep 2006 14:31:32 -0000 1.11 --- test_win32file.py 20 Nov 2006 22:21:48 -0000 1.12 *************** *** 409,412 **** --- 409,422 ---- self.failUnlessEqual(changes, [(1, "test_file")]) + def testSmall(self): + self.stablize() + for dn in self.dir_names: + fn = os.path.join(dn, "x") + open(fn, "w").close() + + self.stablize() + changes = self.watcher_thread_changes[0] + self.failUnlessEqual(changes, [(1, "x")]) + class TestEncrypt(unittest.TestCase): def testEncrypt(self): |
From: Mark H. <mha...@us...> - 2006-11-20 22:21:52
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12889/src Modified Files: win32file.i Log Message: win32file.ReadDirectoryChanges ignored 1 char filenames. >From Niki Spahiev. Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** win32file.i 20 Sep 2006 10:41:06 -0000 1.65 --- win32file.i 20 Nov 2006 22:21:48 -0000 1.66 *************** *** 1554,1558 **** FILE_NOTIFY_INFORMATION *p = (FILE_NOTIFY_INFORMATION *)buffer; PyObject *ret = PyList_New(0); ! if (nbytes < sizeof FILE_NOTIFY_INFORMATION) return ret; DWORD nbytes_read = 0; --- 1554,1562 ---- FILE_NOTIFY_INFORMATION *p = (FILE_NOTIFY_INFORMATION *)buffer; PyObject *ret = PyList_New(0); ! // comparing against the sizeof(FILE_NOTIFY_INFORMATION) fails when ! // the filename is exactly 1 byte! Not clear the best way to ! // check this, but this works for now - is it at least the size of ! // the *head* of the struct. ! if (nbytes < sizeof DWORD*3+2) return ret; DWORD nbytes_read = 0; |
From: Mark H. <mha...@us...> - 2006-11-20 12:36:43
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26808 Modified Files: win32assoc.cpp win32virt.cpp Log Message: Fix a number of Py_DECEFs that happened without the GIL held and other nastiness. Fix [ 1590399 ] Refcounting / GIL problems (dual [core machines]) Thanks to kxroberto for the patch. Index: win32assoc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32assoc.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** win32assoc.cpp 12 Apr 2005 06:02:34 -0000 1.7 --- win32assoc.cpp 20 Nov 2006 12:36:41 -0000 1.8 *************** *** 253,259 **** if (this==NULL) return NULL; if (virtualInst) { DODECREF(this); ! DOINCREF(virtualInst); ! return virtualInst; } else return this; --- 253,260 ---- if (this==NULL) return NULL; if (virtualInst) { + PyObject *vi = virtualInst; + DOINCREF(vi); DODECREF(this); ! return vi; } else return this; Index: win32virt.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32virt.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32virt.cpp 11 Jul 2006 05:18:30 -0000 1.3 --- win32virt.cpp 20 Nov 2006 12:36:41 -0000 1.4 *************** *** 34,39 **** } // ok - have the python data type - now see if it has an override. if (py_bob->virtualInst) { - CEnterLeavePython _celp; PyObject *t, *v, *tb; PyErr_Fetch(&t,&v,&tb); --- 34,39 ---- } // ok - have the python data type - now see if it has an override. + CEnterLeavePython _celp; if (py_bob->virtualInst) { PyObject *t, *v, *tb; PyErr_Fetch(&t,&v,&tb); *************** *** 57,73 **** CVirtualHelper::~CVirtualHelper() { ! // XXX - Gross hack for speed. This is called for eachh window message ! // so only grabs the Python lock if the objects need Python, ! if ((retVal && retVal->ob_refcnt==1) || ! (handler && handler->ob_refcnt==1) || ! (py_ob && py_ob->ob_refcnt==1)) { CEnterLeavePython _celp; XDODECREF(retVal); XDODECREF(handler); XDODECREF(py_ob); - } else { - XDODECREF(retVal); - XDODECREF(handler); - XDODECREF(py_ob); } } --- 57,68 ---- CVirtualHelper::~CVirtualHelper() { ! // This is called for each window message, so should be as fast ! // as possible - but DECREF is not atomic on multi-core CPU's, so ! // take the reliable option... ! if (py_ob || handler || retVal) { CEnterLeavePython _celp; XDODECREF(retVal); XDODECREF(handler); XDODECREF(py_ob); } } *************** *** 78,82 **** BOOL CVirtualHelper::do_call(PyObject *args) { - CEnterLeavePython _celp; XDODECREF(retVal); // our old one. retVal = NULL; --- 73,76 ---- *************** *** 120,123 **** --- 114,118 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; return do_call(arglst); } *************** *** 126,129 **** --- 121,125 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("()"); return do_call(arglst); *************** *** 132,135 **** --- 128,132 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("(i)",val); return do_call(arglst); *************** *** 138,141 **** --- 135,139 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("(ii)",val, val2); return do_call(arglst); *************** *** 144,147 **** --- 142,146 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("(iii)",val1, val2, val3); return do_call(arglst); *************** *** 150,153 **** --- 149,153 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("(l)",val); return do_call(arglst); *************** *** 157,160 **** --- 157,161 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("(z)",val); return do_call(arglst); *************** *** 163,166 **** --- 164,168 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("(zi)",val,ival); return do_call(arglst); *************** *** 169,172 **** --- 171,175 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; if (!ob) ob=Py_None; *************** *** 177,180 **** --- 180,184 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; if (!ob) ob=Py_None; *************** *** 187,190 **** --- 191,195 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; if (!ob) ob=Py_None; *************** *** 198,201 **** --- 203,207 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *dc = (PyObject *) ui_assoc_object::make (ui_dc_object::type, pDC)->GetGoodRet(); *************** *** 209,212 **** --- 215,219 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *dc = (PyObject *) ui_assoc_object::make (ui_dc_object::type, pDC)->GetGoodRet(); *************** *** 233,236 **** --- 240,244 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *info = NULL; PyObject *arglst; *************** *** 250,253 **** --- 258,262 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *wnd = PyWinObject_FromCWnd(pWnd); if (!wnd) return FALSE; *************** *** 261,264 **** --- 270,274 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *wnd = PyWinObject_FromCWnd(pWnd); if (!wnd) return FALSE; *************** *** 272,275 **** --- 282,286 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *wnd = PyWinObject_FromCWnd(pWnd); if (!wnd) return FALSE; *************** *** 283,286 **** --- 294,298 ---- { PyObject *wnd ; + CEnterLeavePython _celp; if (pWnd==NULL) { wnd = Py_None; *************** *** 306,309 **** --- 318,322 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; if (!ob) ob=Py_None; *************** *** 325,328 **** --- 338,342 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *wnd1; if (pWnd1) { *************** *** 351,354 **** --- 365,369 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *doc = (PyObject *) ui_assoc_object::make (PyCDocument::type, pDoc)->GetGoodRet(); *************** *** 362,365 **** --- 377,381 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *cs = PyObjectFromCreateStruct(lpcs); if (!cs) return FALSE; *************** *** 373,376 **** --- 389,393 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *cs = PyObjectFromCreateStruct(lpcs); if (!cs) return FALSE; *************** *** 384,387 **** --- 401,405 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("((iiiii(ii)))",msg->hwnd,msg->message,msg->wParam,msg->lParam,msg->time,msg->pt.x,msg->pt.y); BOOL ret = do_call(arglst); *************** *** 392,395 **** --- 410,414 ---- { if (!handler) return FALSE; + CEnterLeavePython _celp; PyObject *arglst = Py_BuildValue("iill",nID, nCode, (long)pExtra, (long)pHandlerInfo); BOOL ret = do_call(arglst); |
From: Mark H. <mha...@us...> - 2006-11-20 12:35:03
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26063/pywin/framework/editor Modified Files: document.py Log Message: Use shutil.copy2 instead of os.rename for the backup file to prevent potential problems with links - and the operation is logically a copy rather than a rename. Index: document.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/editor/document.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** document.py 4 Jun 2000 06:04:03 -0000 1.8 --- document.py 20 Nov 2006 12:35:01 -0000 1.9 *************** *** 9,12 **** --- 9,13 ---- import traceback import win32api + import shutil BAK_NONE=0 *************** *** 68,72 **** pass try: ! os.rename(fileName, bakFileName) except (os.error, NameError): pass --- 69,76 ---- pass try: ! # Do a copy as it might be on different volumes, ! # and the file may be a hard-link, causing the link ! # to follow the backup. ! shutil.copy2(fileName, bakFileName) except (os.error, NameError): pass |
From: Mark H. <mha...@us...> - 2006-10-11 07:55:12
|
Update of /cvsroot/pywin32/pywin32/isapi/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24145 Modified Files: PythonEng.cpp PythonEng.h pyISAPI.cpp Log Message: Fix one or 2 early exits which would have resulted in the thread lock not being released correctly, which could lead to a deadlock! Bit the bullet and moved to a class based scheme using the destructor to release, meaning even ones I didn't notice get fixed and making these much less likely in the future. Index: pyISAPI.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/pyISAPI.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pyISAPI.cpp 17 Mar 2006 01:05:34 -0000 1.3 --- pyISAPI.cpp 11 Oct 2006 07:55:10 -0000 1.4 *************** *** 73,77 **** PyObject *resultobject = NULL; bool bRetStatus = true; ! PyGILState_STATE state = PyGILState_Ensure(); // create the Python object --- 73,77 ---- PyObject *resultobject = NULL; bool bRetStatus = true; ! CEnterLeavePython celp; // create the Python object *************** *** 92,96 **** } Py_XDECREF(resultobject); - PyGILState_Release(state); return bRetStatus; } --- 92,95 ---- *************** *** 99,103 **** { DWORD result; ! PyGILState_STATE state = PyGILState_Ensure(); CControlBlock * pcb = new CControlBlock(pECB); // PyECB takes ownership of pcb - so when it dies, so does pcb. --- 98,102 ---- { DWORD result; ! CEnterLeavePython celp; CControlBlock * pcb = new CControlBlock(pECB); // PyECB takes ownership of pcb - so when it dies, so does pcb. *************** *** 123,127 **** Py_DECREF(pyECB); Py_XDECREF(resultobject); - PyGILState_Release(state); return result; } --- 122,125 ---- *************** *** 131,135 **** // extension is being terminated BOOL bRetStatus; ! PyGILState_STATE state = PyGILState_Ensure(); PyObject *resultobject = extensionHandler.Callback(HANDLER_TERM, "(i)", dwFlags); if (! resultobject) { --- 129,133 ---- // extension is being terminated BOOL bRetStatus; ! CEnterLeavePython celp; PyObject *resultobject = extensionHandler.Callback(HANDLER_TERM, "(i)", dwFlags); if (! resultobject) { *************** *** 147,151 **** } Py_XDECREF(resultobject); - PyGILState_Release(state); extensionHandler.Term(); return bRetStatus; --- 145,148 ---- *************** *** 161,165 **** return FALSE; ! PyGILState_STATE state = PyGILState_Ensure(); PyFILTER_VERSION *pyFV = new PyFILTER_VERSION(pVer); PyObject *resultobject = filterHandler.Callback(HANDLER_INIT, "(N)", pyFV); --- 158,162 ---- return FALSE; ! CEnterLeavePython celp; PyFILTER_VERSION *pyFV = new PyFILTER_VERSION(pVer); PyObject *resultobject = filterHandler.Callback(HANDLER_INIT, "(N)", pyFV); *************** *** 179,183 **** } Py_XDECREF(resultobject); - PyGILState_Release(state); return bRetStatus; } --- 176,179 ---- *************** *** 186,190 **** { DWORD action; ! PyGILState_STATE state = PyGILState_Ensure(); PyObject *resultobject = NULL; --- 182,186 ---- { DWORD action; ! CEnterLeavePython celp; PyObject *resultobject = NULL; *************** *** 215,219 **** Py_DECREF(pyHFC); Py_XDECREF(resultobject); - PyGILState_Release(state); return action; } --- 211,214 ---- *************** *** 224,228 **** { BOOL bRetStatus; ! PyGILState_STATE state = PyGILState_Ensure(); PyObject *resultobject = filterHandler.Callback(HANDLER_TERM, "(i)", status); if (! resultobject) { --- 219,223 ---- { BOOL bRetStatus; ! CEnterLeavePython celp; PyObject *resultobject = filterHandler.Callback(HANDLER_TERM, "(i)", status); if (! resultobject) { *************** *** 240,244 **** } Py_XDECREF(resultobject); - PyGILState_Release(state); // filter is being terminated filterHandler.Term(); --- 235,238 ---- Index: PythonEng.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/PythonEng.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PythonEng.cpp 9 Sep 2006 03:32:00 -0000 1.3 --- PythonEng.cpp 11 Oct 2006 07:55:10 -0000 1.4 *************** *** 85,89 **** if (isapi_package) m_reload_exception = PyObject_GetAttrString(isapi_package, ! "InternalReloadException"); Py_XDECREF(isapi_package); PyGILState_Release(old_state); --- 85,89 ---- if (isapi_package) m_reload_exception = PyObject_GetAttrString(isapi_package, ! "InternalReloadException"); Py_XDECREF(isapi_package); PyGILState_Release(old_state); *************** *** 190,194 **** char szErrBuf[1024]; PyObject *m; ! PyGILState_STATE old_state = PyGILState_Ensure(); m = PyImport_ImportModule(m_engine->m_module_name); if (m && reload) { --- 190,194 ---- char szErrBuf[1024]; PyObject *m; ! CEnterLeavePython celp; m = PyImport_ImportModule(m_engine->m_module_name); if (m && reload) { *************** *** 210,215 **** } Py_DECREF(m); ! } ! PyGILState_Release(old_state); return m_handler != NULL; } --- 210,214 ---- } Py_DECREF(m); ! } return m_handler != NULL; } *************** *** 221,225 **** return true; // already have the callback. ! PyGILState_STATE old_state = PyGILState_Ensure(); if (!m_handler) { PyErr_SetString(PyExc_RuntimeError, "The handler failed to load"); --- 220,224 ---- return true; // already have the callback. ! CEnterLeavePython celp; if (!m_handler) { PyErr_SetString(PyExc_RuntimeError, "The handler failed to load"); *************** *** 229,233 **** if (!*cb) ExtensionError(NULL, "Failed to locate the callback"); - PyGILState_Release(old_state); return (*cb) != NULL; } --- 228,231 ---- *************** *** 354,358 **** char *windows_error = ::GetLastError() ? ::FormatSysError(::GetLastError()) : NULL; ! PyGILState_STATE s = PyGILState_Ensure(); PySys_WriteStderr("Internal Extension Error: %s\n", errmsg); if (windows_error) --- 352,357 ---- char *windows_error = ::GetLastError() ? ::FormatSysError(::GetLastError()) : NULL; ! { // temp scope to release python lock ! CEnterLeavePython celp; PySys_WriteStderr("Internal Extension Error: %s\n", errmsg); if (windows_error) *************** *** 362,366 **** PyErr_Clear(); } ! PyGILState_Release(s); if (pcb) { char *htmlStream = HTMLErrorResp(errmsg); --- 361,365 ---- PyErr_Clear(); } ! } // end temp scope if (pcb) { char *htmlStream = HTMLErrorResp(errmsg); *************** *** 382,386 **** void FilterError(CFilterContext *pfc, LPCTSTR errmsg) { ! PyGILState_STATE s = PyGILState_Ensure(); PySys_WriteStderr("Internal Filter Error: %s\n", errmsg); if (PyErr_Occurred()) { --- 381,385 ---- void FilterError(CFilterContext *pfc, LPCTSTR errmsg) { ! CEnterLeavePython celp; PySys_WriteStderr("Internal Filter Error: %s\n", errmsg); if (PyErr_Occurred()) { *************** *** 388,392 **** PyErr_Clear(); } - PyGILState_Release(s); // what else to do here? AddResponseHeaders->WriteClient? } --- 387,390 ---- Index: PythonEng.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/PythonEng.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonEng.h 6 Oct 2004 05:11:53 -0000 1.1 --- PythonEng.h 11 Oct 2006 07:55:10 -0000 1.2 *************** *** 94,96 **** --- 94,106 ---- void ExtensionError(CControlBlock *pcb, LPCTSTR errmsg); void FilterError(CFilterContext *pfc, LPCTSTR errmsg); + + class CEnterLeavePython { + public: + CEnterLeavePython() : state(PyGILState_Ensure()) {;} + ~CEnterLeavePython() {PyGILState_Release(state);} + protected: + PyGILState_STATE state; + + }; + #endif // __PythonEngine_H \ No newline at end of file |
From: Mark H. <mha...@us...> - 2006-09-23 00:31:55
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21902 Modified Files: setup.py CHANGES.txt Log Message: Build 210 Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** setup.py 13 Sep 2006 00:30:49 -0000 1.51 --- setup.py 23 Sep 2006 00:31:53 -0000 1.52 *************** *** 1,3 **** ! build_id="209.2" # may optionally include a ".{patchno}" suffix. # Putting buildno at the top prevents automatic __doc__ assignment, and # I *want* the build number at the top :) --- 1,3 ---- ! build_id="210" # may optionally include a ".{patchno}" suffix. # Putting buildno at the top prevents automatic __doc__ assignment, and # I *want* the build number at the top :) Index: CHANGES.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/CHANGES.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CHANGES.txt 16 Jul 2006 11:42:06 -0000 1.6 --- CHANGES.txt 23 Sep 2006 00:31:53 -0000 1.7 *************** *** 6,9 **** --- 6,31 ---- However contributors are encouraged to add their own entries for their work. + Build 210 - Sept. 23 2006 + ------------------------- + * Roger created win32profile module for working with user profiles + * Roger created win32cred module - interface to credentials management + * Roger added win32file functions for backing up and restoring encrypted files + * Add win32api.GetModuleFileNameW(), SetEnvironmentVariable() + * win32file.AcceptEx now indicates if the function was successful. + * OVERLAPPED objects are now hashable [ 1408485 ] + * Roger added win32file.ReplaceFile, CopyFileEx and MoveFileWithProgress + * Added win32uiole.AfxOleInit, SetMessagePendingDelay, + EnableNotRespondingDialog and EnableBusyDialog. + * win32net gets support for USER_INFO_4 structures + * Roger changes win32file.MoveFileEx to accept NULL for destination, added + SetFileShortName + * Missing typelibs could cause incomplete gen_py cache file [ 1548903 ] + * DISPIDs would sometime be incorrect when multiple typelibs used [ 1457673 ] + * ISAPI filters get support for HTTP_FILTER_AUTHENT and HTTP_FILTER_RAW_DATA + * Prevent ISAPI filters and extensions getting "\\?\c:\" style filenames. + * win32com.shell.shell fixes bug in FILEDESCRIPTORW packing, gets a few + unicode related additions. + * Fix memory leak when passing datetime() objects to COM functions. + Build 209 --------- |
From: Mark H. <mha...@us...> - 2006-09-22 14:32:36
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22405/src Modified Files: PyHANDLE.cpp Log Message: Use _Py_HashPointer Index: PyHANDLE.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyHANDLE.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PyHANDLE.cpp 19 Feb 2006 12:16:35 -0000 1.11 --- PyHANDLE.cpp 22 Sep 2006 14:32:33 -0000 1.12 *************** *** 279,283 **** { // Just use the address. ! return (long)this; } --- 279,283 ---- { // Just use the address. ! return _Py_HashPointer(this); } |
From: Mark H. <mha...@us...> - 2006-09-22 14:31:35
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21985/test Modified Files: test_win32file.py Log Message: [ 1408485 ] OVERLAPPED not hashable Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_win32file.py 21 Jun 2006 12:08:06 -0000 1.10 --- test_win32file.py 22 Sep 2006 14:31:32 -0000 1.11 *************** *** 248,251 **** --- 248,255 ---- self.testCompletionPortsNonQueued(True) + def testHashable(self): + overlapped = pywintypes.OVERLAPPED() + d = {} + d[overlapped] = "hello" class TestFindFiles(unittest.TestCase): |