pywin32-checkins Mailing List for Python for Windows Extensions (Page 120)
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...> - 2005-01-25 04:17:02
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31241 Modified Files: setup.py Log Message: Add gdi32.lib to win32print Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** setup.py 30 Nov 2004 21:30:27 -0000 1.4 --- setup.py 25 Jan 2005 04:16:49 -0000 1.5 *************** *** 825,829 **** ("win32pdh", "", False), ("win32pipe", "", False), ! ("win32print", "winspool user32", False), ("win32process", "advapi32 user32", False, 0x0500), ("win32ras", "rasapi32 user32", False), --- 825,829 ---- ("win32pdh", "", False), ("win32pipe", "", False), ! ("win32print", "winspool user32 gdi32", False), ("win32process", "advapi32 user32", False, 0x0500), ("win32ras", "rasapi32 user32", False), |
From: Roger U. <ru...@us...> - 2005-01-24 09:45:37
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31801/win32/src/win32print Modified Files: win32print.cpp Log Message: Fix compile errors for MSVC6 Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** win32print.cpp 24 Jan 2005 02:07:25 -0000 1.10 --- win32print.cpp 24 Jan 2005 09:45:27 -0000 1.11 *************** *** 795,799 **** WCHAR *servername=NULL, *processorname=NULL; PyObject *observername, *obprocessorname; ! DWORD level=1, bufsize=0, bytes_needed, return_cnt; PyObject *ret=NULL, *tuple_item; // @pyparm string/<o PyUnicode>|ServerName||Name of print server, use None for local machine --- 795,799 ---- WCHAR *servername=NULL, *processorname=NULL; PyObject *observername, *obprocessorname; ! DWORD level=1, bufsize=0, bytes_needed, return_cnt, buf_ind; PyObject *ret=NULL, *tuple_item; // @pyparm string/<o PyUnicode>|ServerName||Name of print server, use None for local machine *************** *** 824,828 **** goto done; di1=(DATATYPES_INFO_1W *)buf; ! for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){ tuple_item=PyWinObject_FromWCHAR(di1->pName); if (tuple_item==NULL){ --- 824,828 ---- goto done; di1=(DATATYPES_INFO_1W *)buf; ! for (buf_ind=0; buf_ind<return_cnt; buf_ind++){ tuple_item=PyWinObject_FromWCHAR(di1->pName); if (tuple_item==NULL){ *************** *** 847,851 **** static PyObject *PyEnumPrinterDrivers(PyObject *self, PyObject *args) { ! DWORD level=1, bufsize=0, bytes_needed, return_cnt; LPBYTE buf=NULL; DRIVER_INFO_1W *di1; --- 847,851 ---- static PyObject *PyEnumPrinterDrivers(PyObject *self, PyObject *args) { ! DWORD level=1, bufsize=0, bytes_needed, return_cnt, i; LPBYTE buf=NULL; DRIVER_INFO_1W *di1; *************** *** 891,895 **** case 1:{ di1=(DRIVER_INFO_1W *)buf; ! for (DWORD i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:u}","Name",di1->pName); if (tuple_item==NULL){ --- 891,895 ---- case 1:{ di1=(DRIVER_INFO_1W *)buf; ! for (i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:u}","Name",di1->pName); if (tuple_item==NULL){ *************** *** 904,908 **** case 2: di2=(DRIVER_INFO_2W *)buf; ! for (DWORD i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u}", "Version",di2->cVersion, --- 904,908 ---- case 2: di2=(DRIVER_INFO_2W *)buf; ! for (i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u}", "Version",di2->cVersion, *************** *** 923,927 **** case 3: di3=(DRIVER_INFO_3W *)buf; ! for (DWORD i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u}", "Version",di3->cVersion, --- 923,927 ---- case 3: di3=(DRIVER_INFO_3W *)buf; ! for (i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u}", "Version",di3->cVersion, *************** *** 946,950 **** case 4: di4=(DRIVER_INFO_4W *)buf; ! for (DWORD i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u}", "Version",di4->cVersion, --- 946,950 ---- case 4: di4=(DRIVER_INFO_4W *)buf; ! for (i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u}", "Version",di4->cVersion, *************** *** 970,974 **** case 5: di5=(DRIVER_INFO_5W *)buf; ! for (DWORD i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:l,s:l,s:l}", "Version",di5->cVersion, --- 970,974 ---- case 5: di5=(DRIVER_INFO_5W *)buf; ! for (i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:l,s:l,s:l}", "Version",di5->cVersion, *************** *** 992,996 **** case 6: di6=(DRIVER_INFO_6W *)buf; ! for (DWORD i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:O&,s:L,s:u,s:u,s:u}", "Version",di6->cVersion, --- 992,996 ---- case 6: di6=(DRIVER_INFO_6W *)buf; ! for (i=0; i<return_cnt; i++){ tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:O&,s:L,s:u,s:u,s:u}", "Version",di6->cVersion, *************** *** 1058,1062 **** PyObject *ret=NULL, *tuple_item; HANDLE hprinter; ! DWORD level=1, bufsize=0, bytes_needed=0, return_cnt; FORM_INFO_1W *fi1; LPBYTE buf=NULL; --- 1058,1062 ---- PyObject *ret=NULL, *tuple_item; HANDLE hprinter; ! DWORD level=1, bufsize=0, bytes_needed=0, return_cnt, buf_ind; FORM_INFO_1W *fi1; LPBYTE buf=NULL; *************** *** 1086,1090 **** goto done; fi1=(FORM_INFO_1W *)buf; ! for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){ tuple_item=PyWin_Object_FromFORM_INFO_1(fi1); if (tuple_item==NULL){ --- 1086,1090 ---- goto done; fi1=(FORM_INFO_1W *)buf; ! for (buf_ind=0; buf_ind<return_cnt; buf_ind++){ tuple_item=PyWin_Object_FromFORM_INFO_1(fi1); if (tuple_item==NULL){ |
From: Roger U. <ru...@us...> - 2005-01-24 02:07:36
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19925/win32/src/win32print Modified Files: win32print.cpp Log Message: Add GetForm, SetForm, AddForm, DeleteForm Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** win32print.cpp 21 Jan 2005 15:17:36 -0000 1.9 --- win32print.cpp 24 Jan 2005 02:07:25 -0000 1.10 *************** *** 21,25 **** typedef BOOL (WINAPI *EnumFormsfunc)(HANDLE,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD); ! EnumFormsfunc enumforms=NULL; // Printer stuff. --- 21,35 ---- typedef BOOL (WINAPI *EnumFormsfunc)(HANDLE,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD); ! static EnumFormsfunc enumforms=NULL; ! typedef BOOL (WINAPI *AddFormfunc)(HANDLE,DWORD,LPBYTE); ! static AddFormfunc addform=NULL; ! typedef BOOL (WINAPI *DeleteFormfunc)(HANDLE, LPWSTR); ! static DeleteFormfunc deleteform=NULL; ! typedef BOOL (WINAPI *GetFormfunc)(HANDLE,LPWSTR,DWORD,LPBYTE,DWORD,LPDWORD); ! static GetFormfunc getform=NULL; ! typedef BOOL (WINAPI *SetFormfunc)(HANDLE, LPWSTR, DWORD, LPBYTE); ! static SetFormfunc setform=NULL; ! ! static PyObject *dummy_tuple=NULL; // Printer stuff. *************** *** 1025,1029 **** } ! // @pymethod (dict,...)|win32print|EnumForms|Lists forms for a printer static PyObject *PyEnumForms(PyObject *self, PyObject *args) { --- 1035,1055 ---- } ! PyObject *PyWin_Object_FromFORM_INFO_1(FORM_INFO_1W *fi1) ! { ! if (fi1==NULL){ ! Py_INCREF(Py_None); ! return Py_None; ! } ! return Py_BuildValue("{s:l,s:u,s:{s:l,s:l},s:{s:l,s:l,s:l,s:l}}", ! "Flags", fi1->Flags, ! "Name", fi1->pName, ! "Size", ! "cx", fi1->Size.cx, "cy", fi1->Size.cy, ! "ImageableArea", ! "left", fi1->ImageableArea.left, "top", fi1->ImageableArea.top, ! "right", fi1->ImageableArea.right, "bottom", fi1->ImageableArea.bottom); ! } ! ! // @pymethod (<o FORM_INFO_1>,...)|win32print|EnumForms|Lists forms for a printer static PyObject *PyEnumForms(PyObject *self, PyObject *args) { *************** *** 1039,1043 **** return NULL; } ! if (!PyArg_ParseTuple(args,"i:EnumForms",&hprinter)) return NULL; (*enumforms)(hprinter, level, buf, bufsize, &bytes_needed, &return_cnt); --- 1065,1069 ---- return NULL; } ! if (!PyArg_ParseTuple(args,"l:EnumForms",&hprinter)) return NULL; (*enumforms)(hprinter, level, buf, bufsize, &bytes_needed, &return_cnt); *************** *** 1061,1072 **** fi1=(FORM_INFO_1W *)buf; for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){ ! tuple_item=Py_BuildValue("{s:l,s:u,s:{s:l,s:l},s:{s:l,s:l,s:l,s:l}}", ! "Flags", fi1->Flags, ! "Name", fi1->pName, ! "Size", ! "cx", fi1->Size.cx, "cy", fi1->Size.cy, ! "ImageableArea", ! "left", fi1->ImageableArea.left, "top", fi1->ImageableArea.top, ! "right", fi1->ImageableArea.right, "bottom", fi1->ImageableArea.bottom); if (tuple_item==NULL){ Py_DECREF(ret); --- 1087,1091 ---- fi1=(FORM_INFO_1W *)buf; for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){ ! tuple_item=PyWin_Object_FromFORM_INFO_1(fi1); if (tuple_item==NULL){ Py_DECREF(ret); *************** *** 1083,1086 **** --- 1102,1255 ---- } + BOOL PyWinObject_AsRECTL(PyObject *obrectl, RECTL *rectl) + { + static char *rectl_keys[]={"left","top","right","bottom",0}; + static char* err_msg="RECTL must be a dictionary containing {left:int, top:int, right:int, bottom:int}"; + if (obrectl->ob_type!=&PyDict_Type){ + PyErr_SetString(PyExc_TypeError,err_msg); + return FALSE; + } + if (PyArg_ParseTupleAndKeywords(dummy_tuple, obrectl, "llll", rectl_keys, + &rectl->left, &rectl->top, &rectl->right, &rectl->bottom)) + return TRUE; + + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, err_msg); + return FALSE; + + } + + BOOL PyWinObject_AsSIZEL(PyObject *obsizel, SIZEL *sizel) + { + static char *sizel_keys[]={"cx","cy",0}; + static char* err_msg="SIZEL must be a dictionary containing {cx:int, cy:int}"; + if (obsizel->ob_type!=&PyDict_Type){ + PyErr_SetString(PyExc_TypeError,err_msg); + return FALSE; + } + if (PyArg_ParseTupleAndKeywords(dummy_tuple, obsizel, "ll", sizel_keys, &sizel->cx, &sizel->cy)) + return TRUE; + + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, err_msg); + return FALSE; + } + + // @object FORM_INFO_1|A dictionary containing FORM_INFO_1W data + // @prop int|Flags|FORM_USER, FORM_BUILTIN, or FORM_PRINTER + // @prop <o PyUnicode>|Name|Name of form + // @prop dict|Size|A dictionary representing a SIZEL structure {'cx':int,'cy':int} + // @prop dict|ImageableArea|A dictionary representing a RECTL structure {'left':int, 'top':int, 'right':int, 'bottom':int} + + BOOL PyWinObject_AsFORM_INFO_1(PyObject *obform, FORM_INFO_1W *fi1) + { + static char *form_keys[]={"Flags","Name","Size","ImageableArea",0}; + static char* err_msg="FORM_INFO_1 must be a dictionary containing {Flags:int, Name:unicode, Size:dict, ImageableArea:dict}"; + if (obform->ob_type!=&PyDict_Type){ + PyErr_SetString(PyExc_TypeError,err_msg); + return FALSE; + } + return PyArg_ParseTupleAndKeywords(dummy_tuple, obform, "luO&O&:FORM_INFO_1", form_keys, &fi1->Flags, &fi1->pName, + PyWinObject_AsSIZEL, &fi1->Size, PyWinObject_AsRECTL, &fi1->ImageableArea); + } + + // @pymethod |win32print|AddForm|Adds a form for a printer + static PyObject *PyAddForm(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + // @pyparm dict|Form||<o FORM_INFO_1> dictionary + // @rdesc Returns None on success, throws an exception otherwise + FORM_INFO_1W fi1; + HANDLE hprinter; + if (addform==NULL){ + PyErr_SetString(PyExc_NotImplementedError,"AddForm does not exist on this version of Windows"); + return NULL; + } + if (!PyArg_ParseTuple(args, "lO&:AddForm", &hprinter, PyWinObject_AsFORM_INFO_1, &fi1)) + return NULL; + if (!(*addform)(hprinter, 1, (LPBYTE)&fi1)) + return PyWin_SetAPIError("AddForm"); + Py_INCREF(Py_None); + return Py_None; + } + + // @pymethod |win32print|DeleteForm|Deletes a form defined for a printer + static PyObject *PyDeleteForm(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + // @pyparm <o PyUnicode>|FormName||Name of form to be deleted + // @rdesc Returns None on success, throws an exception otherwise + HANDLE hprinter; + WCHAR *formname; + if (deleteform==NULL){ + PyErr_SetString(PyExc_NotImplementedError,"DeleteForm does not exist on this version of Windows"); + return NULL; + } + + if (!PyArg_ParseTuple(args, "lu:DeleteForm", &hprinter, &formname)) + return NULL; + if (!(*deleteform)(hprinter, formname)) + return PyWin_SetAPIError("DeleteForm"); + Py_INCREF(Py_None); + return Py_None; + } + // @pymethod |win32print|GetForm|Retrieves information about a form defined for a printer + static PyObject *PyGetForm(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + // @pyparm <o PyUnicode>|FormName||Name of form for which to retrieve info + // @rdesc Returns a <o FORM_INFO_1> dict + HANDLE hprinter; + WCHAR *formname; + DWORD level=1, bufsize=0, bytes_needed=0; + FORM_INFO_1W *fi1=NULL; + LPBYTE buf=NULL; + PyObject *ret=NULL; + + if (getform==NULL){ + PyErr_SetString(PyExc_NotImplementedError,"GetForm does not exist on this version of Windows"); + return NULL; + } + if (!PyArg_ParseTuple(args,"lu:GetForm", &hprinter, &formname)) + return NULL; + (*getform)(hprinter, formname, level, buf, bufsize, &bytes_needed); + if (bytes_needed==0) + return PyWin_SetAPIError("GetForm"); + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL) + return PyErr_Format(PyExc_MemoryError,"GetForm: Unable to allocate %d bytes",bytes_needed); + bufsize=bytes_needed; + if (!(*getform)(hprinter, formname, level, buf, bufsize, &bytes_needed)) + PyWin_SetAPIError("GetForm"); + else{ + fi1=(FORM_INFO_1W *)buf; + ret=PyWin_Object_FromFORM_INFO_1(fi1); + } + free(buf); + return ret; + } + + // @pymethod |win32print|SetForm|Change information for a form + static PyObject *PySetForm(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + // @pyparm <o PyUnicode>|FormName||Name of form + // @pyparm dict|Form||<o FORM_INFO_1> dictionary + // @rdesc Returns None on success + FORM_INFO_1W fi1; + HANDLE hprinter; + WCHAR *formname; + if (setform==NULL){ + PyErr_SetString(PyExc_NotImplementedError,"SetForm does not exist on this version of Windows"); + return NULL; + } + if (!PyArg_ParseTuple(args, "luO&:SetForm", &hprinter, &formname, PyWinObject_AsFORM_INFO_1, &fi1)) + return NULL; + if (!(*setform)(hprinter, formname, 1, (LPBYTE)&fi1)) + return PyWin_SetAPIError("SetForm"); + Py_INCREF(Py_None); + return Py_None; + } + /* List of functions exported by this module */ *************** *** 1114,1117 **** --- 1283,1290 ---- {"EnumPrinterDrivers", PyEnumPrinterDrivers, 1}, //@pymeth EnumPrinterDrivers|Lists installed printer drivers {"EnumForms", PyEnumForms, 1}, //@pymeth EnumForms|Lists forms for a printer + {"AddForm", PyAddForm, 1}, //@pymeth AddForm|Adds a form for a printer + {"DeleteForm", PyDeleteForm, 1}, //@pymeth DeleteForm|Deletes a form defined for a printer + {"GetForm", PyGetForm, 1}, //@pymeth GetForm|Retrieves information about a defined form + {"SetForm", PySetForm, 1}, //@pymeth SetForm|Change information for a form { NULL } }; *************** *** 1172,1182 **** AddConstant(dict, "DI_APPBANDING", DI_APPBANDING); AddConstant(dict, "DI_ROPS_READ_DESTINATION", DI_ROPS_READ_DESTINATION); FARPROC fp; HMODULE hmodule=LoadLibrary("winspool.drv"); if (hmodule!=NULL){ ! fp=GetProcAddress(hmodule,"EnumFormsW"); ! if (fp!=NULL) ! enumforms=(EnumFormsfunc)fp; ! } } --- 1345,1371 ---- AddConstant(dict, "DI_APPBANDING", DI_APPBANDING); AddConstant(dict, "DI_ROPS_READ_DESTINATION", DI_ROPS_READ_DESTINATION); + AddConstant(dict, "FORM_USER", FORM_USER); + AddConstant(dict, "FORM_BUILTIN", FORM_BUILTIN); + AddConstant(dict, "FORM_PRINTER", FORM_PRINTER); FARPROC fp; HMODULE hmodule=LoadLibrary("winspool.drv"); if (hmodule!=NULL){ ! fp=GetProcAddress(hmodule,"EnumFormsW"); ! if (fp!=NULL) ! enumforms=(EnumFormsfunc)fp; ! fp=GetProcAddress(hmodule,"AddFormW"); ! if (fp!=NULL) ! addform=(AddFormfunc)fp; ! fp=GetProcAddress(hmodule,"DeleteFormW"); ! if (fp!=NULL) ! deleteform=(DeleteFormfunc)fp; ! fp=GetProcAddress(hmodule,"GetFormW"); ! if (fp!=NULL) ! getform=(GetFormfunc)fp; ! fp=GetProcAddress(hmodule,"SetFormW"); ! if (fp!=NULL) ! setform=(SetFormfunc)fp; ! } ! dummy_tuple=PyTuple_New(0); } |
From: Roger U. <ru...@us...> - 2005-01-21 15:17:46
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5245/win32/src/win32print Modified Files: win32print.cpp Log Message: Add StartDoc, EndDoc, AbortDoc, EnumForms, EnumPrintProcessorDatatypes, EnumPrinterDrivers Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** win32print.cpp 12 Sep 2004 22:44:04 -0000 1.8 --- win32print.cpp 21 Jan 2005 15:17:36 -0000 1.9 *************** *** 20,23 **** --- 20,25 ---- #include <stdarg.h> + typedef BOOL (WINAPI *EnumFormsfunc)(HANDLE,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD); + EnumFormsfunc enumforms=NULL; // Printer stuff. *************** *** 241,245 **** if (!PyArg_ParseTuple(args, "ii(szz):StartDocPrinter", ! &hprinter, // @pyparm int|hprinter||handle to printer (from OpenPrinter) &level, // @pyparm int|level|1|type of docinfo structure (only docinfo level 1 supported) &pDocName, &pOutputFile, &pDatatype // @pyparm data|tuple||A tuple corresponding to the level parameter. --- 243,247 ---- if (!PyArg_ParseTuple(args, "ii(szz):StartDocPrinter", ! &hprinter, // @pyparm int|hprinter||handle to printer (from <om win32print.OpenPrinter>) &level, // @pyparm int|level|1|type of docinfo structure (only docinfo level 1 supported) &pDocName, &pOutputFile, &pDatatype // @pyparm data|tuple||A tuple corresponding to the level parameter. *************** *** 279,283 **** if (!PyArg_ParseTuple(args, "i:EndDocPrinter", ! &hprinter // @pyparm int|hprinter||handle to printer (from OpenPrinter) )) return NULL; --- 281,285 ---- if (!PyArg_ParseTuple(args, "i:EndDocPrinter", ! &hprinter // @pyparm int|hprinter||handle to printer (from <om win32print.OpenPrinter>) )) return NULL; *************** *** 290,293 **** --- 292,433 ---- } + // @pymethod |win32print|AbortPrinter|Deletes spool file for a printer + static PyObject *PyAbortPrinter(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Handle to printer as returned by <om win32print.OpenPrinter> + HANDLE hprinter; + if (!PyArg_ParseTuple(args, "i:AbortPrinter",&hprinter)) + return NULL; + if (!AbortPrinter(hprinter)) + return PyWin_SetAPIError("AbortPrinter"); + Py_INCREF(Py_None); + return Py_None; + } + + // @pymethod |win32print|StartPagePrinter|Notifies the print spooler that a page is to be printed on specified printer + static PyObject *PyStartPagePrinter(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + HANDLE hprinter; + if (!PyArg_ParseTuple(args, "l:StartPagePrinter", &hprinter)) + return NULL; + if (!StartPagePrinter(hprinter)) + return PyWin_SetAPIError("StartPagePrinter"); + Py_INCREF(Py_None); + return Py_None; + } + + // @pymethod |win32print|EndPagePrinter|Ends a page in a print job + static PyObject *PyEndPagePrinter(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + HANDLE hprinter; + if (!PyArg_ParseTuple(args, "l:EndPagePrinter", &hprinter)) + return NULL; + if (!EndPagePrinter(hprinter)) + return PyWin_SetAPIError("EndPagePrinter"); + Py_INCREF(Py_None); + return Py_None; + } + + // @object DOCINFO|A tuple of information representing a DOCINFO struct + // @prop string/<o PyUnicode>|DocName|Name of document + // @prop string/<o PyUnicode>|Output|Name of output file when printing to file. Use None for normal printing. + // @prop string/<o PyUnicode>|DataType|Type of data to be sent to printer, eg RAW, EMF, TEXT. Use None for printer default. + // @prop int|Type|Flag specifying mode of operation. Can be DI_APPBANDING, DI_ROPS_READ_DESTINATION, or 0 + BOOL PyWinObject_AsDOCINFO(PyObject *obdocinfo, DOCINFO *di) + { + if (!PyTuple_Check(obdocinfo)){ + PyErr_SetString(PyExc_TypeError,"DOCINFO must be a tuple"); + return FALSE; + } + if (!PyArg_ParseTuple(obdocinfo, "zzzl", &di->lpszDocName, &di->lpszOutput, &di->lpszOutput, &di->fwType)) + return FALSE; + return TRUE; + } + + // @pymethod int|win32print|StartDoc|Starts spooling a print job on a printer device context + static PyObject *PyStartDoc(PyObject *self, PyObject *args) + { + // @pyparm int|hdc||Printer device context handle as returned by <om win32gui.CreateDC> + // @pyparm tuple|docinfo||<o DOCINFO> tuple specifying print job parameters + // @rdesc On success, returns the job id of the print job + HDC hdc; + DOCINFO docinfo; + int jobid; + PyObject *obdocinfo; + if (!PyArg_ParseTuple(args, "lO:StartDoc", &hdc, &obdocinfo)) + return NULL; + if (!PyWinObject_AsDOCINFO(obdocinfo, &docinfo)) + return NULL; + jobid=StartDoc(hdc, &docinfo); + if (jobid > 0) + return Py_BuildValue("l",jobid); + return PyWin_SetAPIError("StartDoc"); + } + + // @pymethod |win32print|EndDoc|Stops spooling a print job on a printer device context + static PyObject *PyEndDoc(PyObject *self, PyObject *args) + { + // @pyparm int|hdc||Printer device context handle as returned by <om win32gui.CreateDC> + HDC hdc; + int err; + if (!PyArg_ParseTuple(args, "l:EndDoc", &hdc)) + return NULL; + err=EndDoc(hdc); + if (err > 0){ + Py_INCREF(Py_None); + return Py_None; + } + return PyWin_SetAPIError("EndDoc"); + } + + // @pymethod |win32print|AbortDoc|Cancels a print job + static PyObject *PyAbortDoc(PyObject *self, PyObject *args) + { + // @pyparm int|hdc||Printer device context handle as returned by <om win32gui.CreateDC> + HDC hdc; + int err; + if (!PyArg_ParseTuple(args, "l:AbortDoc", &hdc)) + return NULL; + err=AbortDoc(hdc); + if (err > 0){ + Py_INCREF(Py_None); + return Py_None; + } + return PyWin_SetAPIError("AbortDoc"); + } + + // @pymethod |win32print|StartPage|Starts a page on a printer device context + static PyObject *PyStartPage(PyObject *self, PyObject *args) + { + // @pyparm int|hdc||Printer device context handle as returned by <om win32gui.CreateDC> + HDC hdc; + int err; + if (!PyArg_ParseTuple(args, "l:StartPage", &hdc)) + return NULL; + err=StartPage(hdc); + if (err > 0){ + Py_INCREF(Py_None); + return Py_None; + } + return PyWin_SetAPIError("StartPage"); + } + + // @pymethod |win32print|EndPage|Ends a page on a printer device context + static PyObject *PyEndPage(PyObject *self, PyObject *args) + { + // @pyparm int|hdc||Printer device context handle as returned by <om win32gui.CreateDC> + HDC hdc; + int err; + if (!PyArg_ParseTuple(args, "l:EndPage", &hdc)) + return NULL; + err=EndPage(hdc); + if (err > 0){ + Py_INCREF(Py_None); + return Py_None; + } + return PyWin_SetAPIError("EndPage"); + } // @pymethod int|win32print|WritePrinter|Copies the specified bytes to the specified printer. Suitable for copying raw Postscript or HPGL files to a printer. StartDocPrinter and EndDocPrinter should be called before and after. Returns number of bytes written to printer. *************** *** 576,580 **** // @pyparm <o PyDEVMODE>|DevModeInput||PyDEVMODE that specifies initial configuration, can be None if DM_IN_BUFFER not specified // @pyparm int|Mode||A combination of DM_IN_BUFFER, DM_OUT_BUFFER, and DM_IN_PROMPT - pass 0 to retrieve driver data size ! if (!PyArg_ParseTuple(args,"llsOOl", &hwnd, &hprinter, &devicename, &obdmoutput, &obdminput, &mode)) return NULL; if (!PyWinObject_AsDEVMODE(obdmoutput, &dmoutput, TRUE)) --- 716,720 ---- // @pyparm <o PyDEVMODE>|DevModeInput||PyDEVMODE that specifies initial configuration, can be None if DM_IN_BUFFER not specified // @pyparm int|Mode||A combination of DM_IN_BUFFER, DM_OUT_BUFFER, and DM_IN_PROMPT - pass 0 to retrieve driver data size ! if (!PyArg_ParseTuple(args,"llsOOl:DocumentProperties", &hwnd, &hprinter, &devicename, &obdmoutput, &obdminput, &mode)) return NULL; if (!PyWinObject_AsDEVMODE(obdmoutput, &dmoutput, TRUE)) *************** *** 592,596 **** } ! // @pymethod string,...|win32print|EnumPrintProcessors|List printer providers for specified server and environment static PyObject *PyEnumPrintProcessors(PyObject *self, PyObject *args) { --- 732,736 ---- } ! // @pymethod (string,...)|win32print|EnumPrintProcessors|List printer processors for specified server and environment static PyObject *PyEnumPrintProcessors(PyObject *self, PyObject *args) { *************** *** 602,606 **** // @pyparm string|Server|None|Name of print server, use None for local machine // @pyparm string|Environment|None|Environment - eg 'Windows NT x86' - use None for current client environment ! if (!PyArg_ParseTuple(args,"|zz", &servername, &environment)) return NULL; --- 742,746 ---- // @pyparm string|Server|None|Name of print server, use None for local machine // @pyparm string|Environment|None|Environment - eg 'Windows NT x86' - use None for current client environment ! if (!PyArg_ParseTuple(args,"|zz:EnumPrintProcessors", &servername, &environment)) return NULL; *************** *** 638,641 **** --- 778,1087 ---- } + // @pymethod (<o PyUnicode>,...)|win32print|EnumPrintProcessorDatatypes|List data types that specified print provider recognizes + static PyObject *PyEnumPrintProcessorDatatypes(PyObject *self, PyObject *args) + { + DATATYPES_INFO_1W *di1; + LPBYTE buf=NULL; + WCHAR *servername=NULL, *processorname=NULL; + PyObject *observername, *obprocessorname; + DWORD level=1, bufsize=0, bytes_needed, return_cnt; + PyObject *ret=NULL, *tuple_item; + // @pyparm string/<o PyUnicode>|ServerName||Name of print server, use None for local machine + // @pyparm string/<o PyUnicode>|PrintProcessorName||Name of print processor + if (!PyArg_ParseTuple(args,"OO:EnumPrintProcessorDatatypes", &observername, &obprocessorname)) + return NULL; + if (!PyWinObject_AsWCHAR(observername, &servername, TRUE)) + goto done; + if (!PyWinObject_AsWCHAR(obprocessorname, &processorname, FALSE)) + goto done; + EnumPrintProcessorDatatypesW(servername, processorname, level, buf, bufsize, &bytes_needed, &return_cnt); + if (bytes_needed==0){ + PyWin_SetAPIError("EnumPrintProcessorDatatypes"); + goto done; + } + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"EnumPrintProcessorDatatypes: unable to allocate buffer of size %d", bytes_needed); + goto done; + } + bufsize=bytes_needed; + if (!EnumPrintProcessorDatatypesW(servername, processorname, level, buf, bufsize, &bytes_needed, &return_cnt)){ + PyWin_SetAPIError("EnumPrintProcessorDatatypes"); + goto done; + } + ret=PyTuple_New(return_cnt); + if (ret==NULL) + goto done; + di1=(DATATYPES_INFO_1W *)buf; + for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){ + tuple_item=PyWinObject_FromWCHAR(di1->pName); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret,buf_ind,tuple_item); + di1++; + } + done: + if (servername!=NULL) + PyWinObject_FreeWCHAR(servername); + if (processorname!=NULL) + PyWinObject_FreeWCHAR(processorname); + if (buf!=NULL) + free(buf); + return ret; + } + + // @pymethod (dict,...)|win32print|EnumPrinterDrivers|Lists installed printer drivers + static PyObject *PyEnumPrinterDrivers(PyObject *self, PyObject *args) + { + DWORD level=1, bufsize=0, bytes_needed, return_cnt; + LPBYTE buf=NULL; + DRIVER_INFO_1W *di1; + DRIVER_INFO_2W *di2; + DRIVER_INFO_3W *di3; + DRIVER_INFO_4W *di4; + DRIVER_INFO_5W *di5; + DRIVER_INFO_6W *di6; + PyObject *ret=NULL, *tuple_item; + PyObject *observername=Py_None, *obenvironment=Py_None; + WCHAR *servername=NULL, *environment=NULL; + // @pyparm string/unicode|Server|None|Name of print server, use None for local machine + // @pyparm string/unicode|Environment|None|Environment - eg 'Windows NT x86' - use None for current client environment + // @pyparm int|Level|1|Level of information to return, 1-6 (not all levels are supported on all platforms) + // @rdesc Returns a sequence of dictionaries representing DRIVER_INFO_* structures + // @comm On Win2k and up, 'all' can be passed for environment + if (!PyArg_ParseTuple(args,"|OOl:EnumPrinterDrivers", &observername, &obenvironment, &level)) + return NULL; + if (!PyWinObject_AsWCHAR(observername, &servername, TRUE)) + goto done; + if (!PyWinObject_AsWCHAR(obenvironment, &environment, TRUE)) + goto done; + + EnumPrinterDriversW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt); + if (bytes_needed==0){ + PyWin_SetAPIError("EnumPrinterDrivers"); + goto done; + } + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"EnumPrinterDrivers: unable to allocate buffer of size %d", bytes_needed); + goto done; + } + bufsize=bytes_needed; + if (!EnumPrinterDriversW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt)){ + PyWin_SetAPIError("EnumPrintProcessors"); + goto done; + } + ret=PyTuple_New(return_cnt); + if (ret==NULL) + goto done; + switch (level) + case 1:{ + di1=(DRIVER_INFO_1W *)buf; + for (DWORD i=0; i<return_cnt; i++){ + tuple_item=Py_BuildValue("{s:u}","Name",di1->pName); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret, i, tuple_item); + di1++; + } + break; + case 2: + di2=(DRIVER_INFO_2W *)buf; + for (DWORD i=0; i<return_cnt; i++){ + tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u}", + "Version",di2->cVersion, + "Name",di2->pName, + "Environment",di2->pEnvironment, + "DriverPath",di2->pDriverPath, + "DataFile",di2->pDataFile, + "ConfigFile",di2->pConfigFile); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret, i, tuple_item); + di2++; + } + break; + case 3: + di3=(DRIVER_INFO_3W *)buf; + for (DWORD i=0; i<return_cnt; i++){ + tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u}", + "Version",di3->cVersion, + "Name",di3->pName, + "Environment",di3->pEnvironment, + "DriverPath",di3->pDriverPath, + "DataFile",di3->pDataFile, + "ConfigFile",di3->pConfigFile, + "HelpFile", di3->pHelpFile, + "DependentFiles",di3->pDependentFiles, + "MonitorName",di3->pMonitorName, + "DefaultDataType",di3->pDefaultDataType); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret, i, tuple_item); + di3++; + } + break; + case 4: + di4=(DRIVER_INFO_4W *)buf; + for (DWORD i=0; i<return_cnt; i++){ + tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u}", + "Version",di4->cVersion, + "Name",di4->pName, + "Environment",di4->pEnvironment, + "DriverPath",di4->pDriverPath, + "DataFile",di4->pDataFile, + "ConfigFile",di4->pConfigFile, + "HelpFile", di4->pHelpFile, + "DependentFiles",di4->pDependentFiles, + "MonitorName",di4->pMonitorName, + "DefaultDataType",di4->pDefaultDataType, + "PreviousNames",di4->pszzPreviousNames); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret, i, tuple_item); + di4++; + } + break; + case 5: + di5=(DRIVER_INFO_5W *)buf; + for (DWORD i=0; i<return_cnt; i++){ + tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:l,s:l,s:l}", + "Version",di5->cVersion, + "Name",di5->pName, + "Environment",di5->pEnvironment, + "DriverPath",di5->pDriverPath, + "DataFile",di5->pDataFile, + "ConfigFile",di5->pConfigFile, + "DriverAttributes", di5->dwDriverAttributes, + "DriverVersion",di5->dwDriverVersion, + "ConfigVersion",di5->dwConfigVersion); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret, i, tuple_item); + di5++; + } + break; + case 6: + di6=(DRIVER_INFO_6W *)buf; + for (DWORD i=0; i<return_cnt; i++){ + tuple_item=Py_BuildValue("{s:l,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:u,s:O&,s:L,s:u,s:u,s:u}", + "Version",di6->cVersion, + "Name",di6->pName, + "Environment",di6->pEnvironment, + "DriverPath",di6->pDriverPath, + "DataFile",di6->pDataFile, + "ConfigFile",di6->pConfigFile, + "HelpFile", di6->pHelpFile, + "DependentFiles",di6->pDependentFiles, + "MonitorName",di6->pMonitorName, + "DefaultDataType",di6->pDefaultDataType, + "PreviousNames",di6->pszzPreviousNames, + "DriverDate",PyWinObject_FromFILETIME,&di6->ftDriverDate, + "DriverVersion",di6->dwlDriverVersion, + "MfgName",di6->pszMfgName, + "OEMUrl",di6->pszOEMUrl, + "Provider",di6->pszProvider + ); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret, i, tuple_item); + di6++; + } + break; + default: + PyErr_Format(PyExc_ValueError,"EnumPrinterDrivers: Level %d is not supported", level); + Py_DECREF(ret); + ret=NULL; + } + done: + if (buf!=NULL) + free(buf); + if (servername!=NULL) + PyWinObject_FreeWCHAR(servername); + if (environment!=NULL) + PyWinObject_FreeWCHAR(environment); + return ret; + } + + // @pymethod (dict,...)|win32print|EnumForms|Lists forms for a printer + static PyObject *PyEnumForms(PyObject *self, PyObject *args) + { + // @pyparm int|hprinter||Printer handle as returned by <om win32print.OpenPrinter> + // @rdesc Returns a sequence of dictionaries representing FORM_INFO_1 structures + PyObject *ret=NULL, *tuple_item; + HANDLE hprinter; + DWORD level=1, bufsize=0, bytes_needed=0, return_cnt; + FORM_INFO_1W *fi1; + LPBYTE buf=NULL; + if (enumforms==NULL){ + PyErr_SetString(PyExc_NotImplementedError,"EnumForms does not exist on this version of Windows"); + return NULL; + } + if (!PyArg_ParseTuple(args,"i:EnumForms",&hprinter)) + return NULL; + (*enumforms)(hprinter, level, buf, bufsize, &bytes_needed, &return_cnt); + if (bytes_needed==0){ + PyWin_SetAPIError("EnumForms"); + goto done; + } + buf=(LPBYTE)malloc(bytes_needed); + if (buf==NULL){ + PyErr_Format(PyExc_MemoryError,"EnumForms: unable to allocate buffer of size %d", bytes_needed); + goto done; + } + bufsize=bytes_needed; + if (!(*enumforms)(hprinter, level, buf, bufsize, &bytes_needed, &return_cnt)){ + PyWin_SetAPIError("EnumPrintProcessors"); + goto done; + } + ret=PyTuple_New(return_cnt); + if (ret==NULL) + goto done; + fi1=(FORM_INFO_1W *)buf; + for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){ + tuple_item=Py_BuildValue("{s:l,s:u,s:{s:l,s:l},s:{s:l,s:l,s:l,s:l}}", + "Flags", fi1->Flags, + "Name", fi1->pName, + "Size", + "cx", fi1->Size.cx, "cy", fi1->Size.cy, + "ImageableArea", + "left", fi1->ImageableArea.left, "top", fi1->ImageableArea.top, + "right", fi1->ImageableArea.right, "bottom", fi1->ImageableArea.bottom); + if (tuple_item==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret,buf_ind,tuple_item); + fi1++; + } + done: + if (buf!=NULL) + free(buf); + return ret; + } + + /* List of functions exported by this module */ // @module win32print|A module, encapsulating the Windows Win32 API. *************** *** 649,654 **** {"GetDefaultPrinter", PyGetDefaultPrinter, 1}, // @pymeth GetDefaultPrinter|Returns the default printer. {"SetDefaultPrinter", PySetDefaultPrinter, 1}, // @pymeth SetDefaultPrinter|Sets the default printer. ! {"StartDocPrinter", PyStartDocPrinter, 1}, // @pymeth StartDocPrinter|Notifies the print spooler that a document is to be spooled for printing. Returns the Jobid of the started job. ! {"EndDocPrinter", PyEndDocPrinter, 1}, // @pymeth EndDocPrinter|The EndDocPrinter function ends a print job for the specified printer. {"WritePrinter", PyWritePrinter, 1}, // @pymeth WritePrinter|Copies the specified bytes to the specified printer. StartDocPrinter and EndDocPrinter should be called before and after. Returns number of bytes written to printer. {"EnumJobs", PyEnumJobs, 1}, // @pymeth EnumJobs|Enumerates print jobs on specified printer. --- 1095,1108 ---- {"GetDefaultPrinter", PyGetDefaultPrinter, 1}, // @pymeth GetDefaultPrinter|Returns the default printer. {"SetDefaultPrinter", PySetDefaultPrinter, 1}, // @pymeth SetDefaultPrinter|Sets the default printer. ! {"StartDocPrinter", PyStartDocPrinter, 1}, // @pymeth StartDocPrinter|Notifies the print spooler that a document is to be spooled for printing. Returns the Jobid of the started job. ! {"EndDocPrinter", PyEndDocPrinter, 1}, // @pymeth EndDocPrinter|The EndDocPrinter function ends a print job for the specified printer. ! {"AbortPrinter", PyAbortPrinter, 1}, // @pymeth AbortPrinter|Deletes spool file for printer ! {"StartPagePrinter", PyStartPagePrinter, 1}, // @pymeth StartPagePrinter|Notifies the print spooler that a page is to be printed on specified printer ! {"EndPagePrinter", PyEndPagePrinter, 1}, // @pymeth EndPagePrinter|Ends a page in a print job ! {"StartDoc", PyStartDoc, 1}, // @pymeth StartDoc|Starts spooling a print job on a printer device context ! {"EndDoc", PyEndDoc, 1}, // @pymeth EndDoc|Stops spooling a print job on a printer device context ! {"AbortDoc", PyAbortDoc, 1}, // @pymeth AbortDoc|Cancels print job on a printer device context ! {"StartPage", PyStartPage, 1}, // @pymeth StartPage|Starts a page on a printer device context ! {"EndPage", PyEndPage, 1}, // @pymeth EndPage|Ends a page on a printer device context {"WritePrinter", PyWritePrinter, 1}, // @pymeth WritePrinter|Copies the specified bytes to the specified printer. StartDocPrinter and EndDocPrinter should be called before and after. Returns number of bytes written to printer. {"EnumJobs", PyEnumJobs, 1}, // @pymeth EnumJobs|Enumerates print jobs on specified printer. *************** *** 657,660 **** --- 1111,1117 ---- {"DocumentProperties", PyDocumentProperties, 1}, //@pymeth DocumentProperties|Changes printer configuration {"EnumPrintProcessors", PyEnumPrintProcessors, 1}, //@pymeth EnumPrintProcessors|List printer providers for specified server and environment + {"EnumPrintProcessorDatatypes", PyEnumPrintProcessorDatatypes, 1}, //@pymeth EnumPrintProcessorDatatypes|Lists data types that specified print provider supports + {"EnumPrinterDrivers", PyEnumPrinterDrivers, 1}, //@pymeth EnumPrinterDrivers|Lists installed printer drivers + {"EnumForms", PyEnumForms, 1}, //@pymeth EnumForms|Lists forms for a printer { NULL } }; *************** *** 713,715 **** --- 1170,1182 ---- AddConstant(dict, "JOB_CONTROL_RESUME", JOB_CONTROL_RESUME); AddConstant(dict, "JOB_POSITION_UNSPECIFIED", JOB_POSITION_UNSPECIFIED); + AddConstant(dict, "DI_APPBANDING", DI_APPBANDING); + AddConstant(dict, "DI_ROPS_READ_DESTINATION", DI_ROPS_READ_DESTINATION); + + FARPROC fp; + HMODULE hmodule=LoadLibrary("winspool.drv"); + if (hmodule!=NULL){ + fp=GetProcAddress(hmodule,"EnumFormsW"); + if (fp!=NULL) + enumforms=(EnumFormsfunc)fp; + } } |
From: Mark H. <mha...@us...> - 2005-01-20 06:50:00
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8431 Modified Files: win32gui.i Log Message: Add GetTextExtentPoint32, GetMenuInfo, SetMenuInfo Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** win32gui.i 20 Jan 2005 03:02:32 -0000 1.54 --- win32gui.i 20 Jan 2005 06:49:50 -0000 1.55 *************** *** 2680,2683 **** --- 2680,2711 ---- BOOLAPI ClientToScreen(HWND hWnd,POINT *BOTH); + %{ + // @pyswig cx, cy|GetTextExtentPoint32|Computes the width and height of the specified string of text. + static PyObject *PyGetTextExtentPoint32(PyObject *self, PyObject *args) + { + // @pyparm int|dc||The device context + // @pyparm string|str||The string to measure. + int dc; + PyObject *obString; + if (!PyArg_ParseTuple(args, "iO:GetTextExtentPoint32", &dc, &obString)) + return NULL; + TCHAR *szString = NULL; + DWORD nchars; + if (!PyWinObject_AsTCHAR(obString, &szString, FALSE, &nchars)) + return FALSE; + SIZE size = {0,0}; + BOOL rc; + Py_BEGIN_ALLOW_THREADS + rc = GetTextExtentPoint32( (HDC)dc, szString, nchars, &size); + Py_END_ALLOW_THREADS + PyWinObject_FreeTCHAR(szString); + if (!rc) + return PyWin_SetAPIError("GetTextExtentPoint32"); + return Py_BuildValue("ll", size.cx, size.cy); + } + %} + + %native (GetTextExtentPoint32) PyGetTextExtentPoint32; + // @pyswig int|GetOpenFileName|Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to open. // @rdesc If the user presses OK, the function returns TRUE. Otherwise, use CommDlgExtendedError for error details. *************** *** 2701,2704 **** --- 2729,2746 ---- } + %typemap (python, in) MENUINFO *INPUT (int target_size){ + if (0 != PyObject_AsReadBuffer($source, (const void **)&$target, &target_size)) + return NULL; + if (sizeof MENUINFO != target_size) + return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte string/buffer (got %d bytes)", sizeof MENUINFO, target_size); + } + + %typemap (python,in) MENUINFO *BOTH(int target_size) { + if (0 != PyObject_AsWriteBuffer($source, (void **)&$target, &target_size)) + return NULL; + if (sizeof MENUINFO != target_size) + return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte buffer (got %d bytes)", sizeof MENUINFO, target_size); + } + // @pyswig |InsertMenuItem|Inserts a menu item // @pyparm int|hMenu|| *************** *** 2783,2786 **** --- 2825,2841 ---- ); + // @pyswig |SetMenuInfo|Sets information for a specified menu. + BOOLAPI SetMenuInfo( + HMENU hmenu, // @pyparm int|hmenu||handle to menu + MENUINFO *INPUT // @pyparm <o MENUINFO>|info||menu information in the format of a buffer. + // See win32gui_struct for helper functions. + ); + + // @pyswig |GetMenuInfo|Sets information about a specified menu. + BOOLAPI GetMenuInfo( + HMENU hMenu, // @pyparm int|hmenu||handle to menu + MENUINFO *BOTH // @pyparm buffer|info||A buffer to fill with the information. + ); + BOOLAPI DrawFocusRect(HDC hDC, RECT *INPUT); |
From: Mark H. <mha...@us...> - 2005-01-20 06:49:17
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8294 Modified Files: win32gui_struct.py Log Message: Add MENUINFO structures Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32gui_struct.py 26 May 2004 08:52:25 -0000 1.5 --- win32gui_struct.py 20 Jan 2005 06:49:08 -0000 1.6 *************** *** 142,147 **** win32con.MIIM_DATA | win32con.MIIM_FTYPE | \ win32con.MIIM_ID | win32con.MIIM_STATE | \ ! win32con.MIIM_STRING | win32con.MIIM_SUBMENU | \ ! win32con.MIIM_TYPE if mask & win32con.MIIM_STRING: --- 142,147 ---- win32con.MIIM_DATA | win32con.MIIM_FTYPE | \ win32con.MIIM_ID | win32con.MIIM_STATE | \ ! win32con.MIIM_STRING | win32con.MIIM_SUBMENU ! # Note: No MIIM_TYPE - this screws win2k/98. if mask & win32con.MIIM_STRING: *************** *** 169,172 **** --- 169,234 ---- return array.array("c", buf), extra + # MENUINFO struct + menuinfo_fmt = '7i' + + def PackMENUINFO(dwStyle = None, cyMax = None, + hbrBack = None, dwContextHelpID = None, dwMenuData = None, + fMask = 0): + if dwStyle is None: dwStyle = 0 + else: fMask |= win32con.MIM_STYLE + if cyMax is None: cyMax = 0 + else: fMask |= win32con.MIM_MAXHEIGHT + if hbrBack is None: hbrBack = 0 + else: fMask |= win32con.MIM_BACKGROUND + if dwContextHelpID is None: dwContextHelpID = 0 + else: fMask |= win32con.MIM_HELPID + if dwMenuData is None: dwMenuData = 0 + else: fMask |= win32con.MIM_MENUDATA + # Create the struct. + item = struct.pack( + menuinfo_fmt, + struct.calcsize(menuinfo_fmt), # cbSize + fMask, + dwStyle, + cyMax, + hbrBack, + dwContextHelpID, + dwMenuData) + return array.array("c", item) + + def UnpackMENUINFO(s): + (cb, + fMask, + dwStyle, + cyMax, + hbrBack, + dwContextHelpID, + dwMenuData) = struct.unpack(menuinfo_fmt, s) + assert cb==len(s) + if fMask & win32con.MIM_STYLE==0: dwStyle = None + if fMask & win32con.MIM_MAXHEIGHT==0: cyMax = None + if fMask & win32con.MIM_BACKGROUND==0: hbrBack = None + if fMask & win32con.MIM_HELPID==0: dwContextHelpID = None + if fMask & win32con.MIM_MENUDATA==0: dwMenuData = None + return dwStyle, cyMax, hbrBack, dwContextHelpID, dwMenuData + + def EmptyMENUINFO(mask = None): + if mask is None: + mask = win32con.MIM_STYLE | win32con.MIM_MAXHEIGHT| \ + win32con.MIM_BACKGROUND | win32con.MIM_HELPID | \ + win32con.MIM_MENUDATA + + buf = struct.pack( + menuinfo_fmt, + struct.calcsize(menuinfo_fmt), # cbSize + mask, + 0, #dwStyle + 0, #cyMax + 0, #hbrBack, + 0, #dwContextHelpID, + 0, #dwMenuData, + ) + return array.array("c", buf) + ########################################################################## # *************** *** 406,410 **** if not (mask & commctrl.LVCF_FMT): fmt = None if not (mask & commctrl.LVCF_WIDTH): cx = None ! if not (mask & commctrl.LVCF_TEXT): text_addr = test_size = None if not (mask & commctrl.LVCF_SUBITEM): subItem = None if not (mask & commctrl.LVCF_IMAGE): image = None --- 468,472 ---- if not (mask & commctrl.LVCF_FMT): fmt = None if not (mask & commctrl.LVCF_WIDTH): cx = None ! if not (mask & commctrl.LVCF_TEXT): text_addr = text_size = None if not (mask & commctrl.LVCF_SUBITEM): subItem = None if not (mask & commctrl.LVCF_IMAGE): image = None |
From: Mark H. <mha...@us...> - 2005-01-20 03:02:47
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27134 Modified Files: win32gui.i Log Message: Ensure all functions prototyped as a simple "int" release the thread lock. This includes win32gui.MessageBox (which up until now, did not release it. GetWindowText releases the thread-lock. Autoduck corrections. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** win32gui.i 1 Dec 2004 00:07:03 -0000 1.53 --- win32gui.i 20 Jan 2005 03:02:32 -0000 1.54 *************** *** 119,122 **** --- 119,130 ---- %} + // Custom 'exception handlers' for simple types that exist only to + // manage the thread-lock. + %typemap(python,except) int { + Py_BEGIN_ALLOW_THREADS + $function + Py_END_ALLOW_THREADS + } + %apply HCURSOR {long}; typedef long HCURSOR; *************** *** 1644,1647 **** --- 1652,1660 ---- PyObject *obList, *obDlgProc; BOOL bFreeString = FALSE; + // @pyparm int|hinst|| + // @pyparm object|controlList|| + // @pyparm int|hwnd|| + // @pyparm object|dlgproc|| + // @pyparm int|param|0| if (!PyArg_ParseTuple(args, "lOlO|l", &hinst, &obList, &hwnd, &obDlgProc, ¶m)) return NULL; *************** *** 1680,1683 **** --- 1693,1701 ---- PyObject *obList, *obDlgProc; BOOL bFreeString = FALSE; + // @pyparm int|hinst|| + // @pyparm object|controlList|| + // @pyparm int|hwnd|| + // @pyparm object|dlgproc|| + // @pyparm int|param|0| if (!PyArg_ParseTuple(args, "lOlO|l", &hinst, &obList, &hwnd, &obDlgProc, ¶m)) return NULL; *************** *** 1747,1751 **** --- 1765,1771 ---- if (!PyArg_ParseTuple(args, "l", &hwnd)) return NULL; + Py_BEGIN_ALLOW_THREADS len = GetWindowText(hwnd, buffer, sizeof(buffer)/sizeof(TCHAR)); + Py_END_ALLOW_THREADS if (len == 0) return PyUnicodeObject_FromString(""); return PyWinObject_FromTCHAR(buffer, len); *************** *** 1991,1996 **** #define CLR_NONE CLR_NONE - - // @pyswig int|MessageBox|Displays a message box // @pyparm int|parent||The parent window --- 2011,2014 ---- *************** *** 2686,2690 **** // @pyparm int|hMenu|| // @pyparm int|fByPosition|| ! // @pyparm buffer|menuItem||A string or buffer in the format of a MENUITEMINFO structure. BOOLAPI InsertMenuItem(HMENU hMenu, UINT uItem, BOOL fByPosition, MENUITEMINFO *INPUT); --- 2704,2708 ---- // @pyparm int|hMenu|| // @pyparm int|fByPosition|| ! // @pyparm buffer|menuItem||A string or buffer in the format of a <o MENUITEMINFO> structure. BOOLAPI InsertMenuItem(HMENU hMenu, UINT uItem, BOOL fByPosition, MENUITEMINFO *INPUT); *************** *** 2692,2696 **** // @pyparm int|hMenu|| // @pyparm int|fByPosition|| ! // @pyparm buffer|menuItem||A string or buffer in the format of a MENUITEMINFO structure. BOOLAPI SetMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, MENUITEMINFO *INPUT); --- 2710,2714 ---- // @pyparm int|hMenu|| // @pyparm int|fByPosition|| ! // @pyparm buffer|menuItem||A string or buffer in the format of a <o MENUITEMINFO> structure. BOOLAPI SetMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, MENUITEMINFO *INPUT); *************** *** 2698,2702 **** // @pyparm int|hMenu|| // @pyparm int|fByPosition|| ! // @pyparm buffer|menuItem||A string or buffer in the format of a MENUITEMINFO structure. BOOLAPI GetMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, MENUITEMINFO *BOTH); --- 2716,2720 ---- // @pyparm int|hMenu|| // @pyparm int|fByPosition|| ! // @pyparm buffer|menuItem||A string or buffer in the format of a <o MENUITEMINFO> structure. BOOLAPI GetMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, MENUITEMINFO *BOTH); |
From: Roger U. <ru...@us...> - 2005-01-19 21:16:29
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6420/win32/src Modified Files: PySECURITY_DESCRIPTOR.cpp Log Message: Check that a security descriptor created from a buffer is self-relative Index: PySECURITY_DESCRIPTOR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PySECURITY_DESCRIPTOR.cpp 8 Jan 2005 03:14:36 -0000 1.13 --- PySECURITY_DESCRIPTOR.cpp 19 Jan 2005 21:16:20 -0000 1.14 *************** *** 67,70 **** --- 67,83 ---- }; + BOOL _IsSelfRelative(PSECURITY_DESCRIPTOR psd) + { + // check if SD is relative or absolute + SECURITY_DESCRIPTOR_CONTROL sdc; + DWORD revision; + if (!::GetSecurityDescriptorControl(psd, &sdc, &revision)){ + return NULL; + } + if (sdc&SE_SELF_RELATIVE) + return TRUE; + return FALSE; + } + // @pymethod <o PySECURITY_DESCRIPTOR>|pywintypes|SECURITY_DESCRIPTOR|Creates a new SECURITY_DESCRIPTOR object PyObject *PyWinMethod_NewSECURITY_DESCRIPTOR(PyObject *self, PyObject *args) *************** *** 88,91 **** --- 101,108 ---- return NULL; } + if (!_IsSelfRelative(psd)){ + PyErr_SetString(PyExc_ValueError,"Security descriptor created from a buffer must be self relative"); + return NULL; + } return new PySECURITY_DESCRIPTOR(psd); } *************** *** 113,129 **** } - BOOL _IsSelfRelative(PSECURITY_DESCRIPTOR psd) - { - // check if SD is relative or absolute - SECURITY_DESCRIPTOR_CONTROL sdc; - DWORD revision; - if (!::GetSecurityDescriptorControl(psd, &sdc, &revision)){ - return NULL; - } - if (sdc&SE_SELF_RELATIVE) - return TRUE; - return FALSE; - } - // @pymethod |PySECURITY_DESCRIPTOR|IsSelfRelative|Returns 1 if security descriptor is self relative, 0 if absolute PyObject *PySECURITY_DESCRIPTOR::IsSelfRelative(PyObject *self, PyObject *args) --- 130,133 ---- |
From: Roger U. <ru...@us...> - 2005-01-13 06:29:45
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19016/win32/src/win32net Modified Files: win32netfile.cpp Log Message: Clean up argument checking, add Autoduck comments Index: win32netfile.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netfile.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32netfile.cpp 29 Dec 2001 05:30:32 -0000 1.3 --- win32netfile.cpp 13 Jan 2005 06:29:32 -0000 1.4 *************** *** 1,2 **** --- 1,3 ---- + // @doc // Implemented and contributed by Roger Upole. #include "stdio.h" *************** *** 10,22 **** #include "win32net.h" PyObject * PyNetFileEnum(PyObject *self, PyObject *args) - { ! PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; ! PyObject *base_path_obj = NULL; LPTSTR base_path = NULL; ! PyObject *user_name_obj =NULL; LPTSTR user_name = NULL; --- 11,28 ---- #include "win32net.h" + // @pymethod (dict,...)|win32net|NetFileEnum|Lists remotely opened resources on a server PyObject * PyNetFileEnum(PyObject *self, PyObject *args) { ! // @pyparm int|level||Level of information, 2 or 3 supported ! // @pyparm string/<o PyUnicode>|servername|None|The name of the server for which to list open resources, local machine assumed if None ! // @pyparm string/<o PyUnicode>|basepath|None|If specified, limits returned list to files on given path ! // @pyparm string/<o PyUnicode>|username|None|User that opened resource, or None to list open files for all users ! // @rdesc Returns a sequence of dictionaries representing FILE_INFO_* structs, depending on level specified ! PyObject *server_name_obj = Py_None; LPTSTR server_name = NULL; ! PyObject *base_path_obj = Py_None; LPTSTR base_path = NULL; ! PyObject *user_name_obj = Py_None; LPTSTR user_name = NULL; *************** *** 36,43 **** NET_API_STATUS nStatus; - long rc; long info_lvl=NULL; ! if (!PyArg_ParseTuple(args, "iO|OO", &info_lvl, &server_name_obj, &base_path_obj, &user_name_obj)) return NULL; if ((info_lvl != 2) && (info_lvl != 3)){ --- 42,48 ---- NET_API_STATUS nStatus; long info_lvl=NULL; ! if (!PyArg_ParseTuple(args, "i|OOO", &info_lvl, &server_name_obj, &base_path_obj, &user_name_obj)) return NULL; if ((info_lvl != 2) && (info_lvl != 3)){ *************** *** 46,56 **** } ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE); ! if (PyTuple_Size(args)>2){ ! rc = PyWinObject_AsWCHAR(base_path_obj, &base_path, TRUE); ! }; ! if (PyTuple_Size(args)>3){ ! rc = PyWinObject_AsWCHAR(user_name_obj, &user_name, TRUE); ! }; ret_list = PyList_New(0); --- 51,60 ---- } ! if (!PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE)) ! goto done; ! if (!PyWinObject_AsWCHAR(base_path_obj, &base_path, TRUE)) ! goto done; ! if (!PyWinObject_AsWCHAR(user_name_obj, &user_name, TRUE)) ! goto done; ret_list = PyList_New(0); *************** *** 128,133 **** } } ! ! PyWinObject_FreeWCHAR(server_name); if (base_path != NULL) PyWinObject_FreeWCHAR(base_path); --- 132,138 ---- } } ! done: ! if (server_name!=NULL) ! PyWinObject_FreeWCHAR(server_name); if (base_path != NULL) PyWinObject_FreeWCHAR(base_path); *************** *** 137,158 **** } PyObject * PyNetFileClose(PyObject *self, PyObject *args) - { PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; NET_API_STATUS nStatus; long file_id; - long rc; if (!PyArg_ParseTuple(args, "Oi", &server_name_obj, &file_id)) return NULL; ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE); Py_BEGIN_ALLOW_THREADS nStatus=NetFileClose(server_name, file_id); Py_END_ALLOW_THREADS ! PyWinObject_FreeWCHAR(server_name); if (nStatus == NERR_Success){ --- 142,166 ---- } + // @pymethod (dict,...)|win32net|NetFileClose|Closes an open network resource on a server PyObject * PyNetFileClose(PyObject *self, PyObject *args) { + // @pyparm string/<o PyUnicode>|servername||Name of server on which to operate, local machine assumed if None + // @pyparm int|fileid||Id of opened resource, as returned by <om win32net.NetFileEnum> PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; NET_API_STATUS nStatus; long file_id; if (!PyArg_ParseTuple(args, "Oi", &server_name_obj, &file_id)) return NULL; ! if (!PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE)) ! return NULL; Py_BEGIN_ALLOW_THREADS nStatus=NetFileClose(server_name, file_id); Py_END_ALLOW_THREADS ! if (server_name!=NULL) ! PyWinObject_FreeWCHAR(server_name); if (nStatus == NERR_Success){ *************** *** 166,173 **** --- 174,185 ---- } + // @pymethod dict|win32net|NetFileGetInfo|Returns information about an open network resource PyObject * PyNetFileGetInfo(PyObject *self, PyObject *args) { + // @pyparm int|level||Level of information to return, 2 or 3 supported + // @pyparm string/<o PyUnicode>|servername||Server on which resource is open, local machine assumed if None + // @pyparm int|fileid||Id of opened resource, as returned by <om win32net.NetFileEnum> PyObject *server_name_obj = NULL; PyObject *ret_dict = NULL; *************** *** 175,179 **** long info_lvl=NULL; DWORD file_id = NULL; - long rc; LPFILE_INFO_3 pTmpBuf3 = NULL; LPFILE_INFO_2 pTmpBuf2= NULL; --- 187,190 ---- *************** *** 187,191 **** } ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, FALSE); switch (info_lvl){ case 2:{ --- 198,203 ---- } ! if (!PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE)) ! return NULL; switch (info_lvl){ case 2:{ *************** *** 226,231 **** } } ! ! PyWinObject_FreeWCHAR(server_name); return ret_dict; } --- 238,243 ---- } } ! if (server_name!=NULL) ! PyWinObject_FreeWCHAR(server_name); return ret_dict; } |
From: Roger U. <ru...@us...> - 2005-01-13 00:10:35
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8694/win32/src/win32net Modified Files: win32netmodule.cpp Log Message: Autoduck fixes Index: win32netmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netmodule.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** win32netmodule.cpp 12 Jan 2005 07:38:20 -0000 1.17 --- win32netmodule.cpp 13 Jan 2005 00:10:26 -0000 1.18 *************** *** 878,882 **** /* Other misc functions */ ! // @method <o PyUnicode>|win32net|NetGetDCName|Returns the name of the primary domain controller (PDC). PyObject *PyNetGetDCName(PyObject *self, PyObject *args) { --- 878,882 ---- /* Other misc functions */ ! // @pymethod <o PyUnicode>|win32net|NetGetDCName|Returns the name of the primary domain controller (PDC). PyObject *PyNetGetDCName(PyObject *self, PyObject *args) { *************** *** 909,913 **** } ! // @method <o PyUnicode>|win32net|NetGetAnyDCName|Returns the name of any domain controller trusted by the specified server. PyObject *PyNetGetAnyDCName(PyObject *self, PyObject *args) { --- 909,913 ---- } ! // @pymethod <o PyUnicode>|win32net|NetGetAnyDCName|Returns the name of any domain controller trusted by the specified server. PyObject *PyNetGetAnyDCName(PyObject *self, PyObject *args) { |
From: Roger U. <ru...@us...> - 2005-01-12 23:38:53
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1270/win32/src/win32net Modified Files: win32netsession.cpp Log Message: Improve argument error handling, add autoduck comments Index: win32netsession.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netsession.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32netsession.cpp 29 Dec 2001 05:30:32 -0000 1.3 --- win32netsession.cpp 12 Jan 2005 23:38:29 -0000 1.4 *************** *** 1,2 **** --- 1,3 ---- + // @doc // Implemented and contributed by Roger Upole. #include "stdio.h" *************** *** 10,21 **** #include "win32net.h" PyObject * PyNetSessionEnum(PyObject *self, PyObject *args) { ! PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; ! PyObject *client_name_obj = NULL; LPTSTR client_name = NULL; ! PyObject *user_name_obj =NULL; LPTSTR user_name = NULL; --- 11,29 ---- #include "win32net.h" + + // @pymethod (dict,...)|win32net|NetSessionEnum|Returns network sessions for a server, limited to single client and/or user if specified. PyObject * PyNetSessionEnum(PyObject *self, PyObject *args) { ! // @pyparm int|level||Level of information requested, currently accepts 0, 1, 2, 10, and 502 ! // @pyparm string/<o PyUnicode>|server|None|The name of the server for which to list sessions, local machine assumed if None ! // @pyparm string/<o PyUnicode>|client|None|Name of client computer, or None to list all computer sessions ! // @pyparm string/<o PyUnicode>|username|None|User name, or None to list all connected users ! // @rdesc Returns a sequence of dictionaries representing SESSION_INFO_* structs, depending on level specified ! PyObject *server_name_obj = Py_None; LPTSTR server_name = NULL; ! PyObject *client_name_obj = Py_None; LPTSTR client_name = NULL; ! PyObject *user_name_obj = Py_None; LPTSTR user_name = NULL; *************** *** 43,71 **** NET_API_STATUS nStatus; ! long rc; ! long info_lvl; ! if (!PyArg_ParseTuple(args, "iO|OO", &info_lvl, &server_name_obj, &client_name_obj, &user_name_obj)) return NULL; ! if ((info_lvl != 0) && (info_lvl != 1) && (info_lvl !=2) && (info_lvl != 10) && (info_lvl != 502)){ PyErr_SetString(PyExc_ValueError,"Invalid level for NetSessionEnum"); return NULL; } ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE); ! if (PyTuple_Size(args)>2){ ! rc = PyWinObject_AsWCHAR(client_name_obj, &client_name, TRUE); ! // wprintf(client_name); ! } ! ! if (PyTuple_Size(args)>3){ ! rc = PyWinObject_AsWCHAR(user_name_obj, &user_name, TRUE); ! // wprintf(user_name); ! } ! ! ! ret_list = PyList_New(0); ! switch (info_lvl){ case 0: { do{ --- 51,73 ---- NET_API_STATUS nStatus; ! long info_lvl; ! if (!PyArg_ParseTuple(args, "i|OOO", &info_lvl, &server_name_obj, &client_name_obj, &user_name_obj)) return NULL; ! if ((info_lvl != 0) && (info_lvl != 1) && (info_lvl !=2) && (info_lvl != 10) && (info_lvl != 502)){ PyErr_SetString(PyExc_ValueError,"Invalid level for NetSessionEnum"); return NULL; } + + if (!PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE)) + goto done; + if (!PyWinObject_AsWCHAR(client_name_obj, &client_name, TRUE)) + goto done; + if (!PyWinObject_AsWCHAR(user_name_obj, &user_name, TRUE)) + goto done; ! ret_list = PyList_New(0); ! switch (info_lvl){ case 0: { do{ *************** *** 264,268 **** } ! PyWinObject_FreeWCHAR(server_name); if (client_name != NULL) PyWinObject_FreeWCHAR(client_name); --- 266,272 ---- } ! done: ! if (server_name != NULL) ! PyWinObject_FreeWCHAR(server_name); if (client_name != NULL) PyWinObject_FreeWCHAR(client_name); *************** *** 272,321 **** } PyObject * PyNetSessionDel(PyObject *self, PyObject *args) { ! PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; ! PyObject *client_name_obj = NULL; LPTSTR client_name = NULL; ! PyObject *user_name_obj =NULL; LPTSTR user_name = NULL; NET_API_STATUS nStatus; ! long rc; ! ! if (!PyArg_ParseTuple(args, "O|OO", &server_name_obj, &client_name_obj, &user_name_obj)) return NULL; ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE); ! if (PyTuple_Size(args)>1) ! rc = PyWinObject_AsWCHAR(client_name_obj, &client_name, TRUE); ! if (PyTuple_Size(args)>2) ! rc = PyWinObject_AsWCHAR(user_name_obj, &user_name, TRUE); ! ! Py_BEGIN_ALLOW_THREADS ! nStatus = NetSessionDel(server_name, client_name, user_name); ! Py_END_ALLOW_THREADS ! ! PyWinObject_FreeWCHAR(server_name); if (client_name != NULL) PyWinObject_FreeWCHAR(client_name); if (user_name != NULL) PyWinObject_FreeWCHAR(user_name); ! ! if (nStatus == NERR_Success){ ! Py_INCREF(Py_None); ! return Py_None; ! } ! else{ ! ReturnNetError("NetSessionDel",nStatus); ! return NULL; ! } } PyObject * PyNetSessionGetInfo(PyObject *self, PyObject *args) { PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; --- 276,331 ---- } + // @pymethod |win32net|NetSessionDel|Disconnects network connections on a server PyObject * PyNetSessionDel(PyObject *self, PyObject *args) { ! // @pyparm string/<o PyUnicode>|server||The name of the server on which to operate, local machine assumed if None or blank ! // @pyparm string/<o PyUnicode>|client|None|Name of client computer, or None ! // @pyparm string/<o PyUnicode>|username|None|User name, or None for all connected users ! // @rdesc Returns None on success ! PyObject *server_name_obj = Py_None; LPTSTR server_name = NULL; ! PyObject *client_name_obj = Py_None; LPTSTR client_name = NULL; ! PyObject *user_name_obj = Py_None; LPTSTR user_name = NULL; NET_API_STATUS nStatus; ! PyObject *ret=NULL; ! if (!PyArg_ParseTuple(args, "|OOO", &server_name_obj, &client_name_obj, &user_name_obj)) return NULL; ! if (PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE) ! &&PyWinObject_AsWCHAR(client_name_obj, &client_name, TRUE) ! &&PyWinObject_AsWCHAR(user_name_obj, &user_name, TRUE)){ ! Py_BEGIN_ALLOW_THREADS ! nStatus = NetSessionDel(server_name, client_name, user_name); ! Py_END_ALLOW_THREADS ! if (nStatus == NERR_Success){ ! Py_INCREF(Py_None); ! ret=Py_None; ! } ! else ! ReturnNetError("NetSessionDel",nStatus); ! } ! if (server_name != NULL) ! PyWinObject_FreeWCHAR(server_name); if (client_name != NULL) PyWinObject_FreeWCHAR(client_name); if (user_name != NULL) PyWinObject_FreeWCHAR(user_name); ! return ret; } + // @pymethod dict|win32net|NetSessionGetInfo|Returns information for a network session from specified client PyObject * PyNetSessionGetInfo(PyObject *self, PyObject *args) { + // @pyparm int|level||Level of information requested, currently accepts 0, 1, 2, 10, and 502 + // @pyparm string/<o PyUnicode>|server||The name of the server on which to operate, None or blank assumes local machine + // @pyparm string/<o PyUnicode>|client||Name of client computer + // @pyparm string/<o PyUnicode>|username||User that established session + // @rdesc Returns a dictionary representing a SESSION_INFO_* struct, depending on level specified PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; *************** *** 332,337 **** LPSESSION_INFO_502 pTmpBuf502; NET_API_STATUS nStatus; - - long rc; long info_lvl; --- 342,345 ---- *************** *** 343,349 **** } ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, FALSE); ! rc = PyWinObject_AsWCHAR(client_name_obj, &client_name, FALSE); ! rc = PyWinObject_AsWCHAR(user_name_obj, &user_name, FALSE); switch (info_lvl){ --- 351,360 ---- } ! if (!PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE)) ! goto done; ! if (!PyWinObject_AsWCHAR(client_name_obj, &client_name, FALSE)) ! goto done; ! if (!PyWinObject_AsWCHAR(user_name_obj, &user_name, FALSE)) ! goto done; switch (info_lvl){ *************** *** 459,466 **** } } ! ! PyWinObject_FreeWCHAR(server_name); ! PyWinObject_FreeWCHAR(client_name); ! PyWinObject_FreeWCHAR(user_name); return ret_dict; } --- 470,480 ---- } } ! done: ! if (server_name!=NULL) ! PyWinObject_FreeWCHAR(server_name); ! if (client_name!=NULL) ! PyWinObject_FreeWCHAR(client_name); ! if (user_name!=NULL) ! PyWinObject_FreeWCHAR(user_name); return ret_dict; } |
From: Roger U. <ru...@us...> - 2005-01-12 07:40:23
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19528/win32/src/win32net Modified Files: win32netuser.cpp Log Message: Autoduck fixes Index: win32netuser.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netuser.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32netuser.cpp 6 Mar 2004 23:55:59 -0000 1.5 --- win32netuser.cpp 12 Jan 2005 07:40:14 -0000 1.6 *************** *** 283,287 **** } ! // @pymethod dict|win32net|NetUserModalsGet|Retrieves global user information on a server. PyObject *PyNetUserModalsSet(PyObject *self, PyObject *args) { --- 283,287 ---- } ! // @pymethod |win32net|NetUserModalsSet|Sets global user parameters on a server. PyObject *PyNetUserModalsSet(PyObject *self, PyObject *args) { *************** *** 289,293 **** // @pyparm int|level||The information level contained in the data // @pyparm mapping|data||A dictionary holding the data in the format of <o PyUSER_MODALS_INFO_*>. ! // @pyseeapi NetUserModalsGet return PyDoSetModalsInfo(self, args, NetUserModalsSet, "NetUserModalsSet", user_modals_infos); } --- 289,293 ---- // @pyparm int|level||The information level contained in the data // @pyparm mapping|data||A dictionary holding the data in the format of <o PyUSER_MODALS_INFO_*>. ! // @pyseeapi NetUserModalsSet return PyDoSetModalsInfo(self, args, NetUserModalsSet, "NetUserModalsSet", user_modals_infos); } |
From: Roger U. <ru...@us...> - 2005-01-12 07:38:30
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19247/win32/src/win32net Modified Files: win32net.h win32netmisc.cpp win32netmodule.cpp Log Message: Add NetValidateName Index: win32netmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netmodule.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** win32netmodule.cpp 12 Jun 2004 07:51:53 -0000 1.16 --- win32netmodule.cpp 12 Jan 2005 07:38:20 -0000 1.17 *************** *** 38,41 **** --- 38,42 ---- #include "assert.h" + /*****************************************************************************/ /* error helpers */ *************** *** 1008,1011 **** --- 1009,1013 ---- extern PyObject * PyNetFileClose(PyObject *self, PyObject *args); extern PyObject * PyNetFileGetInfo(PyObject *self, PyObject *args); + extern PyObject * PyNetValidateName(PyObject *self, PyObject *args); /* List of functions exported by this module */ *************** *** 1083,1086 **** --- 1085,1089 ---- {"NetFileGetInfo", PyNetFileGetInfo, 1}, // @pymeth NetFileGetInfo|Get info about files open on the server. {"NetStatisticsGet", PyNetStatisticsGet, 1}, // @pymeth NetStatisticsGet|Return server or workstation stats + {"NetValidateName", PyNetValidateName, 1}, // @pymeth NetValidateName|Verify that computer/domain name is valid for given context {NULL, NULL} }; *************** *** 1113,1115 **** --- 1116,1124 ---- AddConstant(dict, "USE_FORCE", USE_FORCE); AddConstant(dict, "USE_LOTS_OF_FORCE", USE_LOTS_OF_FORCE); + + HMODULE hmodule=GetModuleHandle(_T("netapi32")); + if (hmodule==NULL) + hmodule=LoadLibrary(_T("netapi32")); + if (hmodule!=NULL) + pfnNetValidateName=(NetValidateNamefunc)GetProcAddress(hmodule,"NetValidateName"); } Index: win32net.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32net.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32net.h 20 Feb 2001 14:35:43 -0000 1.2 --- win32net.h 12 Jan 2005 07:38:10 -0000 1.3 *************** *** 60,61 **** --- 60,64 ---- PyObject *PyDoGroupDelMembers(PyObject *self, PyObject *args); + + typedef NET_API_STATUS (NET_API_FUNCTION *NetValidateNamefunc)(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, NETSETUP_NAME_TYPE); + extern NetValidateNamefunc pfnNetValidateName; Index: win32netmisc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netmisc.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** win32netmisc.cpp 8 Sep 2004 23:28:16 -0000 1.9 --- win32netmisc.cpp 12 Jan 2005 07:38:20 -0000 1.10 *************** *** 1104,1108 **** } ! // @pymethod (list|win32net|NetServerDiskEnum|Retrieves the list of disk drives on a server. // @rdesc The result is a list of drives on the server PyObject * --- 1104,1108 ---- } ! // @pymethod list|win32net|NetServerDiskEnum|Retrieves the list of disk drives on a server. // @rdesc The result is a list of drives on the server PyObject * *************** *** 1155,1158 **** --- 1155,1160 ---- } + // @pymethod dict|win32net|NetStatisticsGet|Retrieves network statistics for specified service on specified machine + // @rdesc The result is a dictionary representing a STAT_SERVER_0 or STAT_WORKSTATION_0 struct PyObject * PyNetStatisticsGet(PyObject *self, PyObject *args) *************** *** 1267,1268 **** --- 1269,1314 ---- return ret; } + + extern "C" NetValidateNamefunc pfnNetValidateName=NULL; + // @pymethod |win32net|NetValidateName|Checks that domain/machine/workgroup name is valid for given context + // @rdesc Returns none if valid, exception if not + // @comm If Account and Password aren't passed, current logon credentials are used + PyObject * + PyNetValidateName(PyObject *self, PyObject *args) + { + // @pyparm string/<o PyUnicode>|Server||Name of server on which to execute (None or blank uses local) + // @pyparm string/<o PyUnicode>|Name||Machine, domain, or workgroup name to validate + // @pyparm int|NameType||Type of name to validate - from NETSETUP_NAME_TYPE enum (win32net.NetSetup*) + // @pyparm string/<o PyUnicode>|Account|None|Account name to use while validating, current security context is used if not specified + // @pyparm string/<o PyUnicode>|Password|None|Password for Account + PyObject *obServer, *obName, *obAccount=Py_None, *obPassword=Py_None, *ret=NULL; + WCHAR *Server=NULL, *Name=NULL, *Account=NULL, *Password=NULL; + NET_API_STATUS err; + NETSETUP_NAME_TYPE NameType; + if (pfnNetValidateName==NULL){ + PyErr_SetString(PyExc_NotImplementedError,"NetValidateName does not exist on this platform"); + return NULL; + } + if (!PyArg_ParseTuple(args, "OOl|OO",&obServer, &obName, &NameType, &obAccount, &obPassword)) + return NULL; + if (PyWinObject_AsWCHAR(obServer, &Server, TRUE) + &&PyWinObject_AsWCHAR(obName, &Name, FALSE) + &&PyWinObject_AsWCHAR(obAccount, &Account, TRUE) + &&PyWinObject_AsWCHAR(obPassword, &Password, TRUE)){ + err=(*pfnNetValidateName)(Server, Name, Account, Password, NameType); + if (err==NERR_Success) + ret=Py_None; + else + ReturnNetError("NetValidateName", err); + } + if (Server) + PyWinObject_FreeWCHAR(Server); + if (Name) + PyWinObject_FreeWCHAR(Name); + if (Account) + PyWinObject_FreeWCHAR(Account); + if (Password) + PyWinObject_FreeWCHAR(Password); + Py_XINCREF(ret); + return ret; + } |
From: Roger U. <ru...@us...> - 2005-01-12 02:21:59
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2262/win32/Lib Modified Files: win32netcon.py Log Message: Add NETSETUP_NAME_TYPE constants for NetValidateName Index: win32netcon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32netcon.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32netcon.py 15 Apr 2004 07:56:22 -0000 1.3 --- win32netcon.py 12 Jan 2005 02:21:48 -0000 1.4 *************** *** 636,637 **** --- 636,645 ---- WNCON_SLOWLINK = 4 WNCON_DYNAMIC = 8 + + ## NETSETUP_NAME_TYPE, used with NetValidateName + NetSetupUnknown = 0 + NetSetupMachine = 1 + NetSetupWorkgroup = 2 + NetSetupDomain = 3 + NetSetupNonExistentDomain = 4 + NetSetupDnsMachine = 5 |
From: Roger U. <ru...@us...> - 2005-01-08 03:14:46
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31107/win32/src Modified Files: PySECURITY_DESCRIPTOR.cpp Log Message: Allow pywintypes.SECURITY_DESCRIPTOR() to accept any buffer object that contains a valid security descriptor Index: PySECURITY_DESCRIPTOR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PySECURITY_DESCRIPTOR.cpp 26 Jul 2004 06:47:16 -0000 1.12 --- PySECURITY_DESCRIPTOR.cpp 8 Jan 2005 03:14:36 -0000 1.13 *************** *** 70,74 **** PyObject *PyWinMethod_NewSECURITY_DESCRIPTOR(PyObject *self, PyObject *args) { ! long descriptor_len = SECURITY_DESCRIPTOR_MIN_LENGTH; if (PyArg_ParseTuple(args, "|l:SECURITY_DESCRIPTOR", &descriptor_len)) return new PySECURITY_DESCRIPTOR(descriptor_len); --- 70,74 ---- PyObject *PyWinMethod_NewSECURITY_DESCRIPTOR(PyObject *self, PyObject *args) { ! int descriptor_len = SECURITY_DESCRIPTOR_MIN_LENGTH; if (PyArg_ParseTuple(args, "|l:SECURITY_DESCRIPTOR", &descriptor_len)) return new PySECURITY_DESCRIPTOR(descriptor_len); *************** *** 76,87 **** PyErr_Clear(); PyObject *obsd = NULL; // @pyparmalt1 buffer|data||A buffer (eg, a string) with the raw bytes for the security descriptor. if (!PyArg_ParseTuple(args, "O:SECURITY_DESCRIPTOR", &obsd)) return NULL; ! if (!PySECURITY_DESCRIPTOR_Check(obsd)){ ! PyErr_SetString(PyExc_TypeError,"Object is not a PySECURITY_DESCRIPTOR"); return NULL; ! } ! PSECURITY_DESCRIPTOR psd = ((PySECURITY_DESCRIPTOR *)obsd)->GetSD(); return new PySECURITY_DESCRIPTOR(psd); } --- 76,91 ---- PyErr_Clear(); PyObject *obsd = NULL; + PSECURITY_DESCRIPTOR psd; // @pyparmalt1 buffer|data||A buffer (eg, a string) with the raw bytes for the security descriptor. if (!PyArg_ParseTuple(args, "O:SECURITY_DESCRIPTOR", &obsd)) return NULL; ! if (PyObject_AsReadBuffer(obsd, (const void **)&psd, &descriptor_len)==-1){ ! PyErr_SetString(PyExc_TypeError,"Object has no data buffer"); return NULL; ! } ! if (!IsValidSecurityDescriptor(psd)){ ! PyErr_SetString(PyExc_ValueError,"Data is not a valid security descriptor"); ! return NULL; ! } return new PySECURITY_DESCRIPTOR(psd); } |
From: Roger U. <ru...@us...> - 2005-01-08 00:15:21
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24910/win32/src Modified Files: win32service.i Log Message: Add GetServiceDisplayName and GetServiceKeyName, and some autoduck improvements Index: win32service.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32service.i,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32service.i 6 Sep 2004 19:25:08 -0000 1.5 --- win32service.i 8 Jan 2005 00:15:07 -0000 1.6 *************** *** 11,14 **** --- 11,16 ---- #include "PyWinObjects.h" static BOOL (WINAPI *fpQueryServiceStatusEx)(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD) = NULL; + // according to msdn, 256 is limit for service names and service display names + #define MAX_SERVICE_NAME_LEN 256 %} *************** *** 835,838 **** --- 837,842 ---- // These 3 function contributed by Curt Hagenlocher + // @pyswig (tuple,...)|EnumServicesStatus|Returns a tuple of status info for each service that meets specified criteria + // @comm Returns a sequence of tuples representing ENUM_SERVICE_STATUS structs: (ServiceName, DisplayName, <o SERVICE_STATUS>) %native (EnumServicesStatus) MyEnumServicesStatus; *************** *** 840,844 **** static PyObject *MyEnumServicesStatus(PyObject *self, PyObject *args) { ! SC_HANDLE hscm; DWORD serviceType = SERVICE_WIN32; DWORD serviceState = SERVICE_STATE_ALL; --- 844,851 ---- static PyObject *MyEnumServicesStatus(PyObject *self, PyObject *args) { ! // @pyparm int|hSCManager||Handle to service control manager as returned by <om win32service.OpenSCManager> ! // @pyparm int|ServiceType|SERVICE_WIN32|Types of services to enumerate (SERVICE_DRIVER and/or SERVICE_WIN32) ! // @pyparm int|ServiceState|SERVICE_STATE_ALL|Limits to services in specified state ! SC_HANDLE hscm; DWORD serviceType = SERVICE_WIN32; DWORD serviceState = SERVICE_STATE_ALL; *************** *** 899,906 **** --- 906,917 ---- %} + // @pyswig (tuple,...)|EnumDependentServices|Lists services that depend on a service + // @comm Returns a sequence of tuples representing ENUM_SERVICE_STATUS structs: (ServiceName, DisplayName, <o SERVICE_STATUS>) %native (EnumDependentServices) MyEnumDependentServices; %{ static PyObject *MyEnumDependentServices(PyObject *self, PyObject *args) { + // @pyparm int|hService||Handle to service for which to list dependent services (as returned by <om win32service.OpenService>) + // @pyparm int|ServiceState|SERVICE_STATE_ALL|Limits to services in specified state - One of SERVICE_STATE_ALL, SERVICE_ACTIVE, SERVICE_INACTIVE SC_HANDLE hsc; DWORD serviceState = SERVICE_STATE_ALL; *************** *** 961,964 **** --- 972,978 ---- %} + // @pyswig tuple|QueryServiceConfig|Retrieves configuration parameters for a service + // @comm Returns a tuple representing a QUERY_SERVICE_CONFIG struct: + // (ServiceType, StartType, ErrorControl, BinaryPathName, LoadOrderGroup, TagId, Dependencies, ServiceStartName, DisplayName) %native (QueryServiceConfig) MyQueryServiceConfig; *************** *** 966,969 **** --- 980,984 ---- static PyObject *MyQueryServiceConfig(PyObject *self, PyObject *args) { + // @pyparm int|hService||Service handle as returned by <om win32service.OpenService> SC_HANDLE hsc; if (!PyArg_ParseTuple(args, "l:QueryServiceConfig", &hsc)) *************** *** 1191,1198 **** %} ! // @pyswig <o SERVICE_STATUS>|SetServiceStatus|Sets a service status BOOLAPI SetServiceStatus( SERVICE_STATUS_HANDLE hSCManager, // @pyparm int|scHandle||Handle to set ! SERVICE_STATUS *inServiceStatus); // @pyparm object|serviceStatus||The new status // @pyswig <o SERVICE_STATUS>|ControlService|Sends a control message to a service. --- 1206,1263 ---- %} ! // @pyswig <o PyUNICODE>|GetServiceKeyName|Translates a service display name into its registry key name ! %native (GetServiceKeyName) MyGetServiceKeyName; ! %{ ! PyObject *MyGetServiceKeyName(PyObject *self, PyObject *args) ! { ! // @pyparm int|hSCManager||Handle to service control manager as returned by <om win32service.OpenSCManager> ! // @pyparm <o PyUNICODE>|DisplayName||Display name of a service ! SC_HANDLE h; ! WCHAR *displayname; ! WCHAR keyname[MAX_SERVICE_NAME_LEN]; ! DWORD bufsize=MAX_SERVICE_NAME_LEN; ! PyObject *obdisplayname, *ret=NULL; ! if (!PyArg_ParseTuple(args,"lO", &h, &obdisplayname)) ! return NULL; ! if (!PyWinObject_AsWCHAR(obdisplayname, &displayname, FALSE)) ! return NULL; ! if (!GetServiceKeyNameW(h, displayname, keyname, &bufsize)) ! PyWin_SetAPIError("GetServiceKeyName"); ! else ! ret=PyWinObject_FromWCHAR(keyname, bufsize); ! PyWinObject_FreeWCHAR(displayname); ! return ret; ! } ! %} ! ! // @pyswig <o PyUNICODE>|GetServiceDisplayName|Translates an internal service name into its display name ! %native (GetServiceDisplayName) MyGetServiceDisplayName; ! %{ ! PyObject *MyGetServiceDisplayName(PyObject *self, PyObject *args) ! { ! // @pyparm int|hSCManager||Handle to service control manager as returned by <om win32service.OpenSCManager> ! // @pyparm <o PyUNICODE>|ServiceName||Name of service ! SC_HANDLE h; ! WCHAR *keyname; ! WCHAR displayname[MAX_SERVICE_NAME_LEN]; ! DWORD bufsize=MAX_SERVICE_NAME_LEN; ! PyObject *obkeyname, *ret=NULL; ! if (!PyArg_ParseTuple(args,"lO", &h, &obkeyname)) ! return NULL; ! if (!PyWinObject_AsWCHAR(obkeyname, &keyname, FALSE)) ! return NULL; ! if (!GetServiceDisplayNameW(h, keyname, displayname, &bufsize)) ! PyWin_SetAPIError("GetServiceDisplayName"); ! else ! ret=PyWinObject_FromWCHAR(displayname); ! PyWinObject_FreeWCHAR(keyname); ! return ret; ! } ! %} ! ! // @pyswig |SetServiceStatus|Sets a service status BOOLAPI SetServiceStatus( SERVICE_STATUS_HANDLE hSCManager, // @pyparm int|scHandle||Handle to set ! SERVICE_STATUS *inServiceStatus); // @pyparm <o SERVICE_STATUS>|serviceStatus||The new status // @pyswig <o SERVICE_STATUS>|ControlService|Sends a control message to a service. |
From: Roger U. <ru...@us...> - 2005-01-07 06:55:15
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15917/com/win32com/src Modified Files: PyStorage.cpp PythonCOM.cpp Log Message: Add FmtIdToPropStgName & PropStgNameToFmtId Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** PythonCOM.cpp 30 Nov 2004 21:30:27 -0000 1.33 --- PythonCOM.cpp 7 Jan 2005 06:54:56 -0000 1.34 *************** *** 34,37 **** --- 34,40 ---- extern PyObject *pythoncom_StgOpenStorage(PyObject *self, PyObject *args); extern PyObject *pythoncom_StgOpenStorageEx(PyObject *self, PyObject *args); + extern PyObject *pythoncom_FmtIdToPropStgName(PyObject *self, PyObject *args); + extern PyObject *pythoncom_PropStgNameToFmtId(PyObject *self, PyObject *args); + #ifndef MS_WINCE extern PyObject *pythoncom_StgIsStorageFile(PyObject *self, PyObject *args); *************** *** 1582,1585 **** --- 1585,1590 ---- { "UnwrapObject", pythoncom_UnwrapObject, 1 }, // @pymeth UnwrapObject|Unwraps a Python instance in a gateway object. { "Unicode", pythoncom_Unicode, 1 }, // @pymeth Unicode|Converts a string into a <o PyUnicode> object. + { "FmtIdToPropStgName", pythoncom_FmtIdToPropStgName, 1}, //@pymeth FmtIdToPropStgName|Convert a FMTID to its stream name + { "PropStgNameToFmtId", pythoncom_PropStgNameToFmtId, 1}, //@pymeth PropStgNameToFmtId|Convert property set name to FMTID { NULL, NULL } }; Index: PyStorage.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyStorage.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyStorage.cpp 31 Oct 2003 04:41:00 -0000 1.5 --- PyStorage.cpp 7 Jan 2005 06:54:55 -0000 1.6 *************** *** 210,212 **** --- 210,248 ---- } + // @pymethod <o PyUNICODE>|pythoncom|FmtIdToPropStgName|Converts a FMTID to its stream name + PyObject *pythoncom_FmtIdToPropStgName(PyObject *self, PyObject *args) + { + // @pyparm <o PyIID>|fmtid||Format id - a property storage GUID (FMTID_* IIDs) + HRESULT err; + WCHAR oszName[CCH_MAX_PROPSTG_NAME]; + FMTID fmtid; + PyObject *obfmtid=NULL; + if (!PyArg_ParseTuple(args, "O:FmtIdToPropStgName", &obfmtid)) + return NULL; + if (!PyWinObject_AsIID(obfmtid, &fmtid)) + return NULL; + err=FmtIdToPropStgName(&fmtid, oszName); + if (err!=S_OK) + return PyCom_BuildPyException(err); + return PyWinObject_FromWCHAR(oszName); + } + + // @pymethod <o PyIID>|pythoncom|PropStgNameToFmtId|Converts a property set name to its format id (GUID) + PyObject *pythoncom_PropStgNameToFmtId(PyObject *self, PyObject *args) + { + // @pyparm string/unicode|Name||Storage stream name + FMTID fmtid; + WCHAR *oszName=NULL; + HRESULT err; + PyObject *obName=NULL; + if (!PyArg_ParseTuple(args, "O:PropStgNameToFmtId", &obName)) + return NULL; + if (!PyWinObject_AsWCHAR(obName,&oszName)) + return NULL; + err=PropStgNameToFmtId(oszName,&fmtid); + PyWinObject_FreeWCHAR(oszName); + if (err!=S_OK) + return PyCom_BuildPyException(err); + return PyWinObject_FromIID(fmtid); + } |
From: Roger U. <ru...@us...> - 2005-01-07 00:20:33
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30904/win32/Demos Added Files: BackupRead_BackupWrite.py BackupSeek_streamheaders.py Log Message: Demos showing how to use BackupRead, BackupWrite, and BackupSeek to duplicate files and enumerate streams --- NEW FILE: BackupRead_BackupWrite.py --- ## demonstrates using BackupRead and BackupWrite to copy all of a file's data streams import win32file, win32api, win32con, win32security, ntsecuritycon from win32com import storagecon import pythoncom, pywintypes import struct, traceback all_sd_info=win32security.DACL_SECURITY_INFORMATION|win32security.DACL_SECURITY_INFORMATION| \ win32security.OWNER_SECURITY_INFORMATION|win32security.GROUP_SECURITY_INFORMATION tempdir=win32api.GetTempPath() tempfile=win32api.GetTempFileName(tempdir,'bkr')[0] outfile=win32api.GetTempFileName(tempdir,'out')[0] print 'Filename:',tempfile,'Output file:',outfile f=open(tempfile,'w') f.write('some random junk'+'x'*100) f.close() ## add a couple of alternate data streams f=open(tempfile+':streamdata','w') f.write('data written to alternate stream'+'y'*100) f.close() f=open(tempfile+':anotherstream','w') f.write('z'*100) f.close() ## add Summary Information, which is stored as a separate stream m=storagecon.STGM_READWRITE | storagecon.STGM_SHARE_EXCLUSIVE |storagecon.STGM_DIRECT pss=pythoncom.StgOpenStorageEx(tempfile, m, storagecon.STGFMT_FILE, 0 , pythoncom.IID_IPropertySetStorage,None) ps=pss.Create(pythoncom.FMTID_SummaryInformation,pythoncom.IID_IPropertyStorage,0,storagecon.STGM_READWRITE|storagecon.STGM_SHARE_EXCLUSIVE) ps.WriteMultiple((storagecon.PIDSI_KEYWORDS,storagecon.PIDSI_COMMENTS),('keywords','comments')) ps=None pss=None ## add a custom security descriptor to make sure we don't ## get a default that would always be the same for both files in temp dir new_sd=pywintypes.SECURITY_DESCRIPTOR() sid=win32security.LookupAccountName('','EveryOne')[0] acl=pywintypes.ACL() acl.AddAccessAllowedAce(1, win32con.GENERIC_READ, sid) acl.AddAccessAllowedAce(1, ntsecuritycon.FILE_APPEND_DATA, sid) acl.AddAccessAllowedAce(1, win32con.GENERIC_WRITE, sid) acl.AddAccessAllowedAce(1, ntsecuritycon.FILE_ALL_ACCESS, sid) new_sd.SetSecurityDescriptorDacl(True, acl, False) win32security.SetFileSecurity(tempfile,win32security.DACL_SECURITY_INFORMATION,new_sd) sa=pywintypes.SECURITY_ATTRIBUTES() sa.bInheritHandle=True h=win32file.CreateFile(tempfile, win32con.GENERIC_ALL ,win32con.FILE_SHARE_READ, sa, win32con.OPEN_EXISTING, win32file.FILE_FLAG_BACKUP_SEMANTICS , None) outh=win32file.CreateFile(outfile, win32con.GENERIC_ALL ,win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE, sa, win32con.OPEN_EXISTING, win32file.FILE_FLAG_BACKUP_SEMANTICS , None) ctxt=0 outctxt=0 buf=None readsize=100 while 1: bytes_read, buf, ctxt=win32file.BackupRead(h, readsize, buf, False, True, ctxt) if bytes_read==0: break bytes_written, outctxt=win32file.BackupWrite(outh, bytes_read, buf, False, True, outctxt) print 'Written:',bytes_written,'Context:',outctxt win32file.BackupRead(h, 0, buf, True, True, ctxt) win32file.BackupWrite(outh, 0, '', True, True, outctxt) win32file.CloseHandle(h) win32file.CloseHandle(outh) assert open(tempfile).read()==open(outfile).read(),"File contents differ !" assert open(tempfile+':streamdata').read()==open(outfile+':streamdata').read(),"streamdata contents differ !" assert open(tempfile+':anotherstream').read()==open(outfile+':anotherstream').read(),"anotherstream contents differ !" assert buffer(win32security.GetFileSecurity(tempfile,all_sd_info))[:]== \ buffer(win32security.GetFileSecurity(outfile, all_sd_info))[:], "Security descriptors are different !" ## also should check Summary Info programatically --- NEW FILE: BackupSeek_streamheaders.py --- ## demonstrates using BackupSeek to enumerate data streams for a file import win32file, win32api, win32con from win32com import storagecon import pythoncom, pywintypes import struct, traceback stream_types={ win32con.BACKUP_DATA:"Standard data", win32con.BACKUP_EA_DATA:"Extended attribute data", win32con.BACKUP_SECURITY_DATA:"Security descriptor data", win32con.BACKUP_ALTERNATE_DATA:"Alternative data streams", win32con.BACKUP_LINK:"Hard link information", win32con.BACKUP_PROPERTY_DATA:"Property data", win32con.BACKUP_OBJECT_ID:"Objects identifiers", win32con.BACKUP_REPARSE_DATA:"Reparse points", win32con.BACKUP_SPARSE_BLOCK:"Sparse file" } tempdir=win32api.GetTempPath() tempfile=win32api.GetTempFileName(tempdir,'bkr')[0] print 'Filename:',tempfile f=open(tempfile,'w') f.write('some random junk'+'x'*100) f.close() f=open(tempfile+':streamdata','w') f.write('data written to alternate stream'+'y'*100) f.close() f=open(tempfile+':anotherstream','w') f.write('z'*200) f.close() ## add Summary Information, which is stored as a separate stream m=storagecon.STGM_READWRITE | storagecon.STGM_SHARE_EXCLUSIVE |storagecon.STGM_DIRECT pss=pythoncom.StgOpenStorageEx(tempfile, m, storagecon.STGFMT_FILE, 0 , pythoncom.IID_IPropertySetStorage,None) ps=pss.Create(pythoncom.FMTID_SummaryInformation,pythoncom.IID_IPropertyStorage,0,storagecon.STGM_READWRITE|storagecon.STGM_SHARE_EXCLUSIVE) ps.WriteMultiple((storagecon.PIDSI_KEYWORDS,storagecon.PIDSI_COMMENTS),('keywords','comments')) ps=None pss=None sa=pywintypes.SECURITY_ATTRIBUTES() sa.bInheritHandle=False h=win32file.CreateFile(tempfile, win32con.GENERIC_ALL ,win32con.FILE_SHARE_READ, sa, win32con.OPEN_EXISTING, win32file.FILE_FLAG_BACKUP_SEMANTICS , None) """ stream header: typedef struct _WIN32_STREAM_ID { DWORD dwStreamId; DWORD dwStreamAttributes; LARGE_INTEGER Size; DWORD dwStreamNameSize; WCHAR cStreamName[ANYSIZE_ARRAY]; } """ win32_stream_id_format="LLQL" win32_stream_id_size=struct.calcsize(win32_stream_id_format) def parse_stream_header(h,ctxt,data): stream_type, stream_attributes, stream_size, stream_name_size=struct.unpack(win32_stream_id_format,data) print '\nType:',stream_type,stream_types[stream_type], 'Attributes:', stream_attributes, 'Size:', stream_size, 'Name len:',stream_name_size if stream_name_size>0: ## ??? sdk says this size is in characters, but it appears to be number of bytes ??? bytes_read, stream_name_buf, ctxt=win32file.BackupRead(h, stream_name_size, None, False, True, ctxt) stream_name=pywintypes.UnicodeFromRaw(stream_name_buf[:]) else: stream_name='Unnamed' print 'Name:'+stream_name return ctxt, stream_type, stream_attributes, stream_size, stream_name_size, stream_name ctxt=0 win32_stream_id_buf=None ## gets rebound to a writable buffer on first call and reused while 1: bytes_read, win32_stream_id_buf, ctxt=win32file.BackupRead(h, win32_stream_id_size, win32_stream_id_buf, False, True, ctxt) if bytes_read==0: break ctxt, stream_type, stream_attributes, stream_size, stream_name_size, stream_name=\ parse_stream_header(h, ctxt, win32_stream_id_buf[:]) if stream_size>0: bytes_moved=win32file.BackupSeek(h, stream_size, ctxt) print 'Moved: ',bytes_moved win32file.BackupRead(h, win32_stream_id_size, win32_stream_id_buf, True, True, ctxt) win32file.CloseHandle(h) |
From: Roger U. <ru...@us...> - 2005-01-07 00:11:13
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27865/win32/src Modified Files: win32file.i Log Message: Add BackupRead, BackupWrite, and BackupSeek Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** win32file.i 6 Sep 2004 23:49:18 -0000 1.44 --- win32file.i 7 Jan 2005 00:11:03 -0000 1.45 *************** *** 904,908 **** #ifndef MS_WINCE %{ ! // @pyswig <o PyOVERLAPPEDReadBuffer>|AllocateReadBuffer|Allocated a buffer which can be used with an overlapped Read operation using <om win32file.Read> PyObject *MyAllocateReadBuffer(PyObject *self, PyObject *args) { --- 904,908 ---- #ifndef MS_WINCE %{ ! // @pyswig <o PyOVERLAPPEDReadBuffer>|AllocateReadBuffer|Allocated a buffer which can be used with an overlapped Read operation using <om win32file.ReadFile> PyObject *MyAllocateReadBuffer(PyObject *self, PyObject *args) { *************** *** 2627,2630 **** --- 2627,2633 ---- static DWORD (WINAPI *pfnAddUsersToEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_LIST)=NULL; static BOOL (WINAPI *pfnGetVolumePathNameW)(WCHAR *, WCHAR *, DWORD)=NULL; + static BOOL (WINAPI *pfnBackupRead)(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*)=NULL; + static BOOL (WINAPI *pfnBackupSeek)(HANDLE, DWORD, DWORD, LPDWORD, LPDWORD, LPVOID*)=NULL; + static BOOL (WINAPI *pfnBackupWrite)(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*)=NULL; *************** *** 3343,3346 **** --- 3346,3470 ---- } + // @pyswig (int, buffer, int)|BackupRead|Reads streams of data from a file + // @comm Returns number of bytes read, data buffer, and context pointer for next operation + // If Buffer is None, a new buffer will be created of size NbrOfBytesToRead that can be passed + // back in subsequent calls + + static PyObject* + py_BackupRead(PyObject *self, PyObject *args) + { + // @pyparm <o PyHANDLE>|hFile||File handle opened by CreateFile + // @pyparm int|NumberOfBytesToRead||Number of bytes to be read from file + // @pyparm buffer|Buffer||Writeable buffer object that receives data read + // @pyparm int|bAbort||If true, ends read operation and frees backup context + // @pyparm int|bProcessSecurity||Indicates whether file's ACL stream should be read + // @pyparm int|lpContext||Pass 0 on first call, then pass back value returned from last call thereafter + HANDLE h; + BYTE *buf; + int buflen; + DWORD bytes_requested, bytes_read; + BOOL bAbort,bProcessSecurity; + LPVOID ctxt; + PyObject *obbuf=NULL, *obbufout=NULL; + if (pfnBackupRead==NULL) + return PyErr_Format(PyExc_NotImplementedError,"BackupRead not supported by this version of Windows"); + + if (!PyArg_ParseTuple(args, "llOlll", &h, &bytes_requested, &obbuf, &bAbort, &bProcessSecurity, &ctxt)) + return NULL; + if (obbuf==Py_None){ + obbufout=PyBuffer_New(bytes_requested); // ??? any way to create a writable buffer from Python level ??? + if (obbufout==NULL) + return NULL; + if (PyObject_AsWriteBuffer(obbufout, (void **)&buf, &buflen)==-1){ + Py_DECREF(obbufout); + return NULL; + } + } + else{ + obbufout=obbuf; + if (PyObject_AsWriteBuffer(obbufout, (void **)&buf, &buflen)==-1) + return NULL; + if ((DWORD)buflen < bytes_requested) + return PyErr_Format(PyExc_ValueError,"Buffer size (%d) less than requested read size (%d)", buflen, bytes_requested); + Py_INCREF(obbufout); + } + if (!(*pfnBackupRead)(h, buf, bytes_requested, &bytes_read, bAbort, bProcessSecurity, &ctxt)){ + PyWin_SetAPIError("BackupRead"); + Py_DECREF(obbufout); + return NULL; + } + return Py_BuildValue("lNl", bytes_read, obbufout, ctxt); + } + + // @pyswig long|BackupSeek|Seeks forward in a file stream + // @comm Function will only seek to end of current stream, used to seek past bad data + // or find beginning position for read of next stream + // Returns number of bytes actually moved + static PyObject* + py_BackupSeek(PyObject *self, PyObject *args) + { + // @pyparm <o PyHANDLE>|hFile||File handle used by a BackupRead operation + // @pyparm long|NumberOfBytesToSeek||Number of bytes to move forward in current stream + // @pyparm int|lpContext||Context pointer returned from a BackupRead operation + HANDLE h; + ULARGE_INTEGER bytes_to_seek; + ULARGE_INTEGER bytes_moved; + LPVOID ctxt; + PyObject *obbytes_to_seek; + if (pfnBackupSeek==NULL) + return PyErr_Format(PyExc_NotImplementedError,"BackupSeek not supported by this version of Windows"); + if (!PyArg_ParseTuple(args,"lOl", &h, &obbytes_to_seek, &ctxt)) + return NULL; + if (!PyWinObject_AsULARGE_INTEGER(obbytes_to_seek, &bytes_to_seek)) + return NULL; + bytes_moved.QuadPart=0; + if (!(*pfnBackupSeek)(h, bytes_to_seek.LowPart, bytes_to_seek.HighPart, + &bytes_moved.LowPart, &bytes_moved.HighPart, + &ctxt)){ + // function returns false if you attempt to seek past end of current stream, but file pointer + // still moves to start of next stream - consider this as success + if (bytes_moved.QuadPart==0){ + PyWin_SetAPIError("BackupSeek"); + return NULL; + } + } + return PyWinObject_FromULARGE_INTEGER(bytes_moved); + } + + // @pyswig (int,int)|BackupWrite|Restores file data + // @comm Returns number of bytes written and context pointer for next operation + static PyObject* + py_BackupWrite(PyObject *self, PyObject *args) + { + // @pyparm <o PyHANDLE>|hFile||File handle opened by CreateFile + // @pyparm int|NumberOfBytesToWrite||Length of data to be written to file + // @pyparm string|Buffer||A string or buffer object that contains the data to be written + // @pyparm int|bAbort||If true, ends write operation and frees backup context + // @pyparm int|bProcessSecurity||Indicates whether ACL's should be restored + // @pyparm int|lpContext||Pass 0 on first call, then pass back value returned from last call thereafter + HANDLE h; + BYTE *buf; + int buflen; + DWORD bytes_to_write, bytes_written; + BOOL bAbort, bProcessSecurity; + LPVOID ctxt; + PyObject *obbuf; + if (pfnBackupWrite==NULL) + return PyErr_Format(PyExc_NotImplementedError,"BackupWrite not supported by this version of Windows"); + + if (!PyArg_ParseTuple(args, "llOlll", &h, &bytes_to_write, &obbuf, &bAbort, &bProcessSecurity, &ctxt)) + return NULL; + if (PyObject_AsReadBuffer(obbuf, (const void **)&buf, &buflen)==-1) + return NULL; + if ((DWORD)buflen < bytes_to_write) + return PyErr_Format(PyExc_ValueError,"Buffer size (%d) less than requested write size (%d)", buflen, bytes_to_write); + + if (!(*pfnBackupWrite)(h, buf, bytes_to_write, &bytes_written, bAbort, bProcessSecurity, &ctxt)){ + PyWin_SetAPIError("BackupWrite"); + return NULL; + } + return Py_BuildValue("ll", bytes_written, ctxt); + } + %} *************** *** 3360,3363 **** --- 3484,3490 ---- %native (RemoveUsersFromEncryptedFile) py_RemoveUsersFromEncryptedFile; %native (AddUsersToEncryptedFile) py_AddUsersToEncryptedFile; + %native (BackupRead) py_BackupRead; + %native (BackupSeek) py_BackupSeek; + %native (BackupWrite) py_BackupWrite; %init %{ *************** *** 3415,3418 **** --- 3542,3555 ---- fp = GetProcAddress(hmodule, "CreateHardLinkW"); if (fp) pfnCreateHardLinkW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES))(fp); + + fp = GetProcAddress(hmodule, "BackupRead"); + if (fp) pfnBackupRead = (BOOL (WINAPI *)(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*))(fp); + + fp = GetProcAddress(hmodule, "BackupSeek"); + if (fp) pfnBackupSeek = (BOOL (WINAPI *)(HANDLE, DWORD, DWORD, LPDWORD, LPDWORD, LPVOID*))(fp); + + fp = GetProcAddress(hmodule, "BackupWrite"); + if (fp) pfnBackupWrite = (BOOL (WINAPI *)(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*))(fp); + } %} |
From: Roger U. <ru...@us...> - 2005-01-06 22:29:25
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv921/win32/Lib Modified Files: win32con.py Log Message: Add extra backup stream id's Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** win32con.py 6 Dec 2004 00:28:30 -0000 1.8 --- win32con.py 6 Jan 2005 22:29:15 -0000 1.9 *************** *** 4325,4328 **** --- 4325,4332 ---- BACKUP_LINK = 5 BACKUP_PROPERTY_DATA = 6 + BACKUP_OBJECT_ID = 7 + BACKUP_REPARSE_DATA = 8 + BACKUP_SPARSE_BLOCK = 9 + STREAM_NORMAL_ATTRIBUTE = 0 STREAM_MODIFIED_WHEN_READ = 1 *************** *** 4523,4526 **** --- 4527,4565 ---- MOUSE_WHEELED = 4 + #property sheet window messages from prsht.h + PSM_SETCURSEL = (WM_USER + 101) + PSM_REMOVEPAGE = (WM_USER + 102) + PSM_ADDPAGE = (WM_USER + 103) + PSM_CHANGED = (WM_USER + 104) + PSM_RESTARTWINDOWS = (WM_USER + 105) + PSM_REBOOTSYSTEM = (WM_USER + 106) + PSM_CANCELTOCLOSE = (WM_USER + 107) + PSM_QUERYSIBLINGS = (WM_USER + 108) + PSM_UNCHANGED = (WM_USER + 109) + PSM_APPLY = (WM_USER + 110) + PSM_SETTITLEA = (WM_USER + 111) + PSM_SETTITLEW = (WM_USER + 120) + PSM_SETWIZBUTTONS = (WM_USER + 112) + PSM_PRESSBUTTON = (WM_USER + 113) + PSM_SETCURSELID = (WM_USER + 114) + PSM_SETFINISHTEXTA = (WM_USER + 115) + PSM_SETFINISHTEXTW = (WM_USER + 121) + PSM_GETTABCONTROL = (WM_USER + 116) + PSM_ISDIALOGMESSAGE = (WM_USER + 117) + PSM_GETCURRENTPAGEHWND = (WM_USER + 118) + PSM_INSERTPAGE = (WM_USER + 119) + PSM_SETHEADERTITLEA = (WM_USER + 125) + PSM_SETHEADERTITLEW = (WM_USER + 126) + PSM_SETHEADERSUBTITLEA = (WM_USER + 127) + PSM_SETHEADERSUBTITLEW = (WM_USER + 128) + PSM_HWNDTOINDEX = (WM_USER + 129) + PSM_INDEXTOHWND = (WM_USER + 130) + PSM_PAGETOINDEX = (WM_USER + 131) + PSM_INDEXTOPAGE = (WM_USER + 132) + PSM_IDTOINDEX = (WM_USER + 133) + PSM_INDEXTOID = (WM_USER + 134) + PSM_GETRESULT = (WM_USER + 135) + PSM_RECALCPAGESIZES = (WM_USER + 136) + # GetUserNameEx/GetComputerNameEx NameUnknown = 0 |
From: Mark H. <mha...@us...> - 2004-12-16 05:02:33
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv317 Modified Files: PyIQueryAssociations.cpp PyIQueryAssociations.h shell.cpp Log Message: Fix previous fix! Index: PyIQueryAssociations.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIQueryAssociations.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIQueryAssociations.h 15 Dec 2004 01:09:13 -0000 1.1 --- PyIQueryAssociations.h 16 Dec 2004 05:02:21 -0000 1.2 *************** *** 5,8 **** --- 5,56 ---- // Interface Declaration + // The shlwapi.h included with MSVC6 does not have this interface. + // A default Microsoft SDK does not provide an updated shlwapi.h file + // (even though the SDK on mhammond's machine does!). Rather than + // try and figure out these header versions, just copy the interface + // definition here. + // #include "shlwapi.h" + + // *** - start of shlwapi.h clone + enum { + ASSOCF_INIT_NOREMAPCLSID = 0x00000001, // do not remap clsids to progids + ASSOCF_INIT_BYEXENAME = 0x00000002, // executable is being passed in + ASSOCF_OPEN_BYEXENAME = 0x00000002, // executable is being passed in + ASSOCF_INIT_DEFAULTTOSTAR = 0x00000004, // treat "*" as the BaseClass + ASSOCF_INIT_DEFAULTTOFOLDER = 0x00000008, // treat "Folder" as the BaseClass + ASSOCF_NOUSERSETTINGS = 0x00000010, // dont use HKCU + ASSOCF_NOTRUNCATE = 0x00000020, // dont truncate the return string + ASSOCF_VERIFY = 0x00000040, // verify data is accurate (DISK HITS) + ASSOCF_REMAPRUNDLL = 0x00000080, // actually gets info about rundlls target if applicable + ASSOCF_NOFIXUPS = 0x00000100, // attempt to fix errors if found + ASSOCF_IGNOREBASECLASS = 0x00000200, // dont recurse into the baseclass + }; + typedef DWORD ASSOCF; + #define LWSTDAPI STDAPI + typedef enum {} ASSOCSTR; + typedef enum {} ASSOCKEY; + typedef enum {} ASSOCDATA; + typedef enum {} ASSOCENUM; + #undef INTERFACE + #define INTERFACE IQueryAssociations + + DECLARE_INTERFACE_( IQueryAssociations, IUnknown ) + { + // IUnknown methods + STDMETHOD (QueryInterface)(THIS_ REFIID riid, void **ppv) PURE; + STDMETHOD_(ULONG, AddRef) ( THIS ) PURE; + STDMETHOD_(ULONG, Release) ( THIS ) PURE; + + // IQueryAssociations methods + STDMETHOD (Init)(THIS_ ASSOCF flags, LPCWSTR pszAssoc, HKEY hkProgid, HWND hwnd) PURE; + STDMETHOD (GetString)(THIS_ ASSOCF flags, ASSOCSTR str, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut) PURE; + STDMETHOD (GetKey)(THIS_ ASSOCF flags, ASSOCKEY key, LPCWSTR pszExtra, HKEY *phkeyOut) PURE; + STDMETHOD (GetData)(THIS_ ASSOCF flags, ASSOCDATA data, LPCWSTR pszExtra, LPVOID pvOut, DWORD *pcbOut) PURE; + STDMETHOD (GetEnum)(THIS_ ASSOCF flags, ASSOCENUM assocenum, LPCWSTR pszExtra, REFIID riid, LPVOID *ppvOut) PURE; + }; + + LWSTDAPI AssocCreate(CLSID clsid, REFIID riid, LPVOID *ppv); + // *** - end of shlwapi.h clone + class PyIQueryAssociations : public PyIUnknown { Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** shell.cpp 15 Dec 2004 01:09:13 -0000 1.30 --- shell.cpp 16 Dec 2004 05:02:21 -0000 1.31 *************** *** 14,18 **** #include "shell_pch.h" - #include "shlwapi.h" #include "PyIShellLink.h" #include "PyIContextMenu.h" --- 14,17 ---- Index: PyIQueryAssociations.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIQueryAssociations.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyIQueryAssociations.cpp 15 Dec 2004 23:27:49 -0000 1.2 --- PyIQueryAssociations.cpp 16 Dec 2004 05:02:21 -0000 1.3 *************** *** 3,55 **** #include "shell_pch.h" - - // The shlwapi.h included with MSVC6 does not have this interface. - // A default Microsoft SDK does not provide an updated shlwapi.h file - // (even though the SDK on mhammond's machine does!). Rather than - // try and figure out these header versions, just copy the interface - // definition here. - // #include "shlwapi.h" - - // *** - start of shlwapi.h clone - enum { - ASSOCF_INIT_NOREMAPCLSID = 0x00000001, // do not remap clsids to progids - ASSOCF_INIT_BYEXENAME = 0x00000002, // executable is being passed in - ASSOCF_OPEN_BYEXENAME = 0x00000002, // executable is being passed in - ASSOCF_INIT_DEFAULTTOSTAR = 0x00000004, // treat "*" as the BaseClass - ASSOCF_INIT_DEFAULTTOFOLDER = 0x00000008, // treat "Folder" as the BaseClass - ASSOCF_NOUSERSETTINGS = 0x00000010, // dont use HKCU - ASSOCF_NOTRUNCATE = 0x00000020, // dont truncate the return string - ASSOCF_VERIFY = 0x00000040, // verify data is accurate (DISK HITS) - ASSOCF_REMAPRUNDLL = 0x00000080, // actually gets info about rundlls target if applicable - ASSOCF_NOFIXUPS = 0x00000100, // attempt to fix errors if found - ASSOCF_IGNOREBASECLASS = 0x00000200, // dont recurse into the baseclass - }; - typedef DWORD ASSOCF; - #define LWSTDAPI STDAPI - typedef enum {} ASSOCSTR; - typedef enum {} ASSOCKEY; - typedef enum {} ASSOCDATA; - typedef enum {} ASSOCENUM; - #undef INTERFACE - #define INTERFACE IQueryAssociations - - DECLARE_INTERFACE_( IQueryAssociations, IUnknown ) - { - // IUnknown methods - STDMETHOD (QueryInterface)(THIS_ REFIID riid, void **ppv) PURE; - STDMETHOD_(ULONG, AddRef) ( THIS ) PURE; - STDMETHOD_(ULONG, Release) ( THIS ) PURE; - - // IQueryAssociations methods - STDMETHOD (Init)(THIS_ ASSOCF flags, LPCWSTR pszAssoc, HKEY hkProgid, HWND hwnd) PURE; - STDMETHOD (GetString)(THIS_ ASSOCF flags, ASSOCSTR str, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut) PURE; - STDMETHOD (GetKey)(THIS_ ASSOCF flags, ASSOCKEY key, LPCWSTR pszExtra, HKEY *phkeyOut) PURE; - STDMETHOD (GetData)(THIS_ ASSOCF flags, ASSOCDATA data, LPCWSTR pszExtra, LPVOID pvOut, DWORD *pcbOut) PURE; - STDMETHOD (GetEnum)(THIS_ ASSOCF flags, ASSOCENUM assocenum, LPCWSTR pszExtra, REFIID riid, LPVOID *ppvOut) PURE; - }; - - LWSTDAPI AssocCreate(CLSID clsid, REFIID riid, LPVOID *ppv); - // *** - end of shlwapi.h clone - #include "PyIQueryAssociations.h" --- 3,6 ---- |
From: Mark H. <mha...@us...> - 2004-12-15 23:27:58
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv972 Modified Files: PyIQueryAssociations.cpp Log Message: Clone the interface defn from shlwapi.h - the VC 6 one doesn't have it, and the default mssdk doesn't provide an updated the header. Index: PyIQueryAssociations.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIQueryAssociations.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIQueryAssociations.cpp 15 Dec 2004 01:09:13 -0000 1.1 --- PyIQueryAssociations.cpp 15 Dec 2004 23:27:49 -0000 1.2 *************** *** 3,7 **** #include "shell_pch.h" ! #include "shlwapi.h" #include "PyIQueryAssociations.h" --- 3,55 ---- #include "shell_pch.h" ! ! // The shlwapi.h included with MSVC6 does not have this interface. ! // A default Microsoft SDK does not provide an updated shlwapi.h file ! // (even though the SDK on mhammond's machine does!). Rather than ! // try and figure out these header versions, just copy the interface ! // definition here. ! // #include "shlwapi.h" ! ! // *** - start of shlwapi.h clone ! enum { ! ASSOCF_INIT_NOREMAPCLSID = 0x00000001, // do not remap clsids to progids ! ASSOCF_INIT_BYEXENAME = 0x00000002, // executable is being passed in ! ASSOCF_OPEN_BYEXENAME = 0x00000002, // executable is being passed in ! ASSOCF_INIT_DEFAULTTOSTAR = 0x00000004, // treat "*" as the BaseClass ! ASSOCF_INIT_DEFAULTTOFOLDER = 0x00000008, // treat "Folder" as the BaseClass ! ASSOCF_NOUSERSETTINGS = 0x00000010, // dont use HKCU ! ASSOCF_NOTRUNCATE = 0x00000020, // dont truncate the return string ! ASSOCF_VERIFY = 0x00000040, // verify data is accurate (DISK HITS) ! ASSOCF_REMAPRUNDLL = 0x00000080, // actually gets info about rundlls target if applicable ! ASSOCF_NOFIXUPS = 0x00000100, // attempt to fix errors if found ! ASSOCF_IGNOREBASECLASS = 0x00000200, // dont recurse into the baseclass ! }; ! typedef DWORD ASSOCF; ! #define LWSTDAPI STDAPI ! typedef enum {} ASSOCSTR; ! typedef enum {} ASSOCKEY; ! typedef enum {} ASSOCDATA; ! typedef enum {} ASSOCENUM; ! #undef INTERFACE ! #define INTERFACE IQueryAssociations ! ! DECLARE_INTERFACE_( IQueryAssociations, IUnknown ) ! { ! // IUnknown methods ! STDMETHOD (QueryInterface)(THIS_ REFIID riid, void **ppv) PURE; ! STDMETHOD_(ULONG, AddRef) ( THIS ) PURE; ! STDMETHOD_(ULONG, Release) ( THIS ) PURE; ! ! // IQueryAssociations methods ! STDMETHOD (Init)(THIS_ ASSOCF flags, LPCWSTR pszAssoc, HKEY hkProgid, HWND hwnd) PURE; ! STDMETHOD (GetString)(THIS_ ASSOCF flags, ASSOCSTR str, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut) PURE; ! STDMETHOD (GetKey)(THIS_ ASSOCF flags, ASSOCKEY key, LPCWSTR pszExtra, HKEY *phkeyOut) PURE; ! STDMETHOD (GetData)(THIS_ ASSOCF flags, ASSOCDATA data, LPCWSTR pszExtra, LPVOID pvOut, DWORD *pcbOut) PURE; ! STDMETHOD (GetEnum)(THIS_ ASSOCF flags, ASSOCENUM assocenum, LPCWSTR pszExtra, REFIID riid, LPVOID *ppvOut) PURE; ! }; ! ! LWSTDAPI AssocCreate(CLSID clsid, REFIID riid, LPVOID *ppv); ! // *** - end of shlwapi.h clone ! #include "PyIQueryAssociations.h" |
From: Mark H. <mha...@us...> - 2004-12-15 01:09:24
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2867/win32comext/shell Modified Files: shellcon.py Log Message: Add (client only) support for IQueryAssociations Index: shellcon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/shellcon.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** shellcon.py 2 Jul 2004 04:13:13 -0000 1.12 --- shellcon.py 15 Dec 2004 01:09:12 -0000 1.13 *************** *** 881,882 **** --- 881,925 ---- FD_PROGRESSUI = 0x4000 FD_LINKUI = 0x8000 + + # shlwapi stuff + ASSOCF_INIT_NOREMAPCLSID = 0x00000001 # do not remap clsids to progids + ASSOCF_INIT_BYEXENAME = 0x00000002 # executable is being passed in + ASSOCF_OPEN_BYEXENAME = 0x00000002 # executable is being passed in + ASSOCF_INIT_DEFAULTTOSTAR = 0x00000004 # treat "*" as the BaseClass + ASSOCF_INIT_DEFAULTTOFOLDER = 0x00000008 # treat "Folder" as the BaseClass + ASSOCF_NOUSERSETTINGS = 0x00000010 # dont use HKCU + ASSOCF_NOTRUNCATE = 0x00000020 # dont truncate the return string + ASSOCF_VERIFY = 0x00000040 # verify data is accurate (DISK HITS) + ASSOCF_REMAPRUNDLL = 0x00000080 # actually gets info about rundlls target if applicable + ASSOCF_NOFIXUPS = 0x00000100 # attempt to fix errors if found + ASSOCF_IGNOREBASECLASS = 0x00000200 # dont recurse into the baseclass + + ASSOCSTR_COMMAND = 1 # shell\verb\command string + ASSOCSTR_EXECUTABLE = 2 # the executable part of command string + ASSOCSTR_FRIENDLYDOCNAME = 3 # friendly name of the document type + ASSOCSTR_FRIENDLYAPPNAME = 4 # friendly name of executable + ASSOCSTR_NOOPEN = 5 # noopen value + ASSOCSTR_SHELLNEWVALUE = 6 # query values under the shellnew key + ASSOCSTR_DDECOMMAND = 7 # template for DDE commands + ASSOCSTR_DDEIFEXEC = 8 # DDECOMMAND to use if just create a process + ASSOCSTR_DDEAPPLICATION = 9 # Application name in DDE broadcast + ASSOCSTR_DDETOPIC = 10 # Topic Name in DDE broadcast + ASSOCSTR_INFOTIP = 11 # info tip for an item, or list of properties to create info tip from + ASSOCSTR_QUICKTIP = 12 # same as ASSOCSTR_INFOTIP, except, this list contains only quickly retrievable properties + ASSOCSTR_TILEINFO = 13 # similar to ASSOCSTR_INFOTIP - lists important properties for tileview + ASSOCSTR_CONTENTTYPE = 14 # MIME Content type + ASSOCSTR_DEFAULTICON = 15 # Default icon source + ASSOCSTR_SHELLEXTENSION = 16 # Guid string pointing to the Shellex\Shellextensionhandler value. + + ASSOCKEY_SHELLEXECCLASS = 1 # the key that should be passed to ShellExec(hkeyClass) + ASSOCKEY_APP = 2 # the "Application" key for the association + ASSOCKEY_CLASS = 3 # the progid or class key + ASSOCKEY_BASECLASS = 4 # the BaseClass key + + ASSOCDATA_MSIDESCRIPTOR = 1 # Component Descriptor to pass to MSI APIs + ASSOCDATA_NOACTIVATEHANDLER = 2 # restrict attempts to activate window + ASSOCDATA_QUERYCLASSSTORE = 3 # should check with the NT Class Store + ASSOCDATA_HASPERUSERASSOC = 4 # defaults to user specified association + ASSOCDATA_EDITFLAGS = 5 # Edit flags. + ASSOCDATA_VALUE = 6 # use pszExtra as the Value name + |
From: Mark H. <mha...@us...> - 2004-12-15 01:09:24
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2867/win32comext/shell/src Modified Files: shell.cpp Added Files: PyIQueryAssociations.cpp PyIQueryAssociations.h Log Message: Add (client only) support for IQueryAssociations --- NEW FILE: PyIQueryAssociations.h --- // This file declares the IPersistFolder Interface and Gateway for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration class PyIQueryAssociations : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIQueryAssociations); static IQueryAssociations* GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *Init(PyObject *self, PyObject *args); static PyObject *GetKey(PyObject *self, PyObject *args); static PyObject *GetString(PyObject *self, PyObject *args); protected: PyIQueryAssociations(IUnknown *pdisp); ~PyIQueryAssociations(); }; Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** shell.cpp 9 Oct 2004 01:20:48 -0000 1.29 --- shell.cpp 15 Dec 2004 01:09:13 -0000 1.30 *************** *** 14,17 **** --- 14,18 ---- #include "shell_pch.h" + #include "shlwapi.h" #include "PyIShellLink.h" #include "PyIContextMenu.h" *************** *** 30,33 **** --- 31,35 ---- #include "PyIDropTargetHelper.h" #include "PyIAsyncOperation.h" + #include "PyIQueryAssociations.h" #include "PythonCOMRegister.h" // For simpler registration of IIDs etc. *************** *** 1935,1938 **** --- 1937,1964 ---- } + // @pymethod <o PyIQueryAssociations|shell|AssocCreate|Creates a <o PyIQueryAssociations> object + static PyObject *PyAssocCreate(PyObject *self, PyObject *args) + { + if (!PyArg_ParseTuple(args, ":AssocCreate")) + return NULL; + + HMODULE hmod = LoadLibrary(TEXT("shlwapi.dll")); + typedef HRESULT (WINAPI * PFNAssocCreate)(CLSID, REFIID, LPVOID); + PFNAssocCreate pfnAssocCreate = NULL; + if (hmod) pfnAssocCreate=(PFNAssocCreate)GetProcAddress(hmod, "AssocCreate"); + if (pfnAssocCreate==NULL) { + if (hmod) FreeLibrary(hmod); + return OleSetOleError(E_NOTIMPL); + } + HRESULT hr; + IQueryAssociations *pRet = NULL; + PY_INTERFACE_PRECALL; + hr = (*pfnAssocCreate)(CLSID_QueryAssociations, IID_IQueryAssociations, (void **)&pRet); + if (hmod) FreeLibrary(hmod); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + return PyCom_PyObjectFromIUnknown(pRet, IID_IQueryAssociations, FALSE); + } /* List of module functions */ *************** *** 1940,1943 **** --- 1966,1970 ---- static struct PyMethodDef shell_methods[]= { + { "AssocCreate", PyAssocCreate, 1 }, // @pymeth AssocCreate|Creates a <o PyIQueryAssociations> object { "DragQueryFile", PyDragQueryFile, 1 }, // @pymeth DragQueryFile|Retrieves the file names of dropped files that have resulted from a successful drag-and-drop operation. { "DragQueryPoint", PyDragQueryPoint, 1}, // @pymeth DragQueryPoint|Retrieves the position of the mouse pointer at the time a file was dropped during a drag-and-drop operation. *************** *** 1991,1994 **** --- 2018,2022 ---- PYCOM_INTERFACE_FULL(ColumnProvider), PYCOM_INTERFACE_FULL(DropTargetHelper), + PYCOM_INTERFACE_CLIENT_ONLY(QueryAssociations), // IID_ICopyHook doesn't exist - hack it up { &IID_IShellCopyHook, "IShellCopyHook", "IID_IShellCopyHook", &PyICopyHook::type, GET_PYGATEWAY_CTOR(PyGCopyHook) }, --- NEW FILE: PyIQueryAssociations.cpp --- // This file implements the IQueryAssociations Interface and Gateway for Python. // Generated by makegw.py #include "shell_pch.h" #include "shlwapi.h" #include "PyIQueryAssociations.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIQueryAssociations::PyIQueryAssociations(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIQueryAssociations::~PyIQueryAssociations() { } /* static */ IQueryAssociations *PyIQueryAssociations::GetI(PyObject *self) { return (IQueryAssociations *)PyIUnknown::GetI(self); } // @pymethod |PyIQueryAssociations|Init|Initializes the IQueryAssociations interface and sets the root key to the appropriate ProgID. PyObject *PyIQueryAssociations::Init(PyObject *self, PyObject *args) { IQueryAssociations *pIQA = GetI(self); if ( pIQA == NULL ) return NULL; // @pyparm int|flags|| // @pyparm string|assoc||The string data (ie, extension, prog-id, etc) // @pyparm <o PyHANDLE>|hkeyProgId|0| // @pyparm int|hwnd|0|Must be 0 int flags, hwnd=0, hkProgid = 0; PyObject *obAssoc; WCHAR *pszAssoc = NULL; if (!PyArg_ParseTuple(args, "lO|ll:Init", &flags, &obAssoc, &hkProgid, &hwnd)) return NULL; if (!PyWinObject_AsWCHAR(obAssoc, &pszAssoc, TRUE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIQA->Init( flags, pszAssoc, (HKEY)hkProgid, (HWND)hwnd); PyWinObject_FreeWCHAR(pszAssoc); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations ); Py_INCREF(Py_None); return Py_None; } // XXX - GetData not implemented - memory management unclear - XXX // @pymethod int|PyIQueryAssociations|GetKey|Searches for and retrieves a file association-related key from the registry. PyObject *PyIQueryAssociations::GetKey(PyObject *self, PyObject *args) { IQueryAssociations *pIQA = GetI(self); if ( pIQA == NULL ) return NULL; // @pyparm int|flags||Used to control the search. // @pyparm int|assocKey||Specifies the type of key that is to be returned. // @pyparm string||extra|Optional string with information about the location of the key. // It is normally set to a shell verb such as 'open'. Set this parameter to None if it is not used. int flags, assoc; PyObject *obExtra = Py_None; HKEY ret = NULL; WCHAR *pszExtra= NULL; if (!PyArg_ParseTuple(args, "ll|O:GetKey", &flags, &assoc, &obExtra)) return NULL; if (!PyWinObject_AsWCHAR(obExtra, &pszExtra, TRUE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIQA->GetKey( flags, (ASSOCKEY)assoc, pszExtra, &ret); PyWinObject_FreeWCHAR(pszExtra); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations ); return PyLong_FromVoidPtr(ret); } // @pymethod int|PyIQueryAssociations|GetString|Searches for and retrieves a file association-related string from the registry. PyObject *PyIQueryAssociations::GetString(PyObject *self, PyObject *args) { IQueryAssociations *pIQA = GetI(self); if ( pIQA == NULL ) return NULL; // @pyparm int|flags||Used to control the search. // @pyparm int|assocStr||Specifies the type of string that is to be returned. // @pyparm string||extra|Optional string with information about the location of the key. // It is normally set to a shell verb such as 'open'. Set this parameter to None if it is not used. int flags, assoc; PyObject *obExtra = Py_None; HKEY *ret = NULL; WCHAR *pszExtra= NULL; if (!PyArg_ParseTuple(args, "ll|O:GetString", &flags, &assoc, &obExtra)) return NULL; // @comm Note that ASSOCF_NOTRUNCATE semantics are currently not supported - // the buffer passed is 2048 bytes long, and will be truncated by the // shell if too small. WCHAR result_buf[2048]; DWORD result_size = sizeof(result_buf) / sizeof(result_buf[0]); if (flags & ASSOCF_NOTRUNCATE) return PyErr_Format(PyExc_ValueError, "Can not set ASSOCF_NOTRUNCATE - these semantics are not supported"); if (!PyWinObject_AsWCHAR(obExtra, &pszExtra, TRUE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIQA->GetString( flags, (ASSOCSTR)assoc, pszExtra, result_buf, &result_size); PyWinObject_FreeWCHAR(pszExtra); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations ); // docs don't explicitly say if result_size includes NULL. It says: // "will be set to the number of characters actually placed in the buffer" return PyWinObject_FromWCHAR(result_buf, result_size-1); } // @object PyIQueryAssociations|Description of the interface static struct PyMethodDef PyIQueryAssociations_methods[] = { { "Init", PyIQueryAssociations::Init, 1 }, // @pymeth Init|Initializes the IQueryAssociations interface and sets the root key to the appropriate ProgID. { "GetKey", PyIQueryAssociations::GetKey, 1 }, // @pymeth GetKey|Searches for and retrieves a file association-related key from the registry. { "GetString", PyIQueryAssociations::GetString, 1 }, // @pymeth GetString|Searches for and retrieves a file association-related string from the registry. { NULL } }; PyComTypeObject PyIQueryAssociations::type("PyIQueryAssociations", &PyIUnknown::type, sizeof(PyIQueryAssociations), PyIQueryAssociations_methods, GET_PYCOM_CTOR(PyIQueryAssociations)); |
From: Mark H. <mha...@us...> - 2004-12-15 01:09:22
|
Update of /cvsroot/pywin32/pywin32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2867 Modified Files: shell.dsp Log Message: Add (client only) support for IQueryAssociations Index: shell.dsp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/shell.dsp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** shell.dsp 2 Jul 2004 04:14:02 -0000 1.11 --- shell.dsp 15 Dec 2004 01:09:11 -0000 1.12 *************** *** 131,134 **** --- 131,138 ---- # Begin Source File + SOURCE=.\win32comext\shell\src\PyIQueryAssociations.cpp + # End Source File + # Begin Source File + SOURCE=.\win32comext\shell\src\PyIShellBrowser.cpp # End Source File *************** *** 195,198 **** --- 199,206 ---- # Begin Source File + SOURCE=.\win32comext\shell\src\PyIQueryAssociations.h + # End Source File + # Begin Source File + SOURCE=.\win32comext\shell\src\PyIShellBrowser.h # End Source File |