[pywin32-checkins] pywin32/win32/src/win32print win32print.cpp,1.19,1.20
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2005-02-14 19:31:30
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9190/win32/src/win32print Modified Files: win32print.cpp Log Message: Add DeletePrinterDriver and DeletePrinterDriverEx Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** win32print.cpp 14 Feb 2005 15:06:52 -0000 1.19 --- win32print.cpp 14 Feb 2005 19:31:20 -0000 1.20 *************** *** 42,45 **** --- 42,47 ---- static GetPrintProcessorDirectoryfunc pfnGetPrintProcessorDirectory=NULL; static GetPrintProcessorDirectoryfunc pfnGetPrinterDriverDirectory=NULL; // same as GetPrintProcessorDirectory + typedef BOOL (WINAPI *DeletePrinterDriverExfunc)(LPWSTR, LPWSTR, LPWSTR, DWORD, DWORD); + static DeletePrinterDriverExfunc pfnDeletePrinterDriverEx=NULL; static PyObject *dummy_tuple=NULL; *************** *** 2215,2218 **** --- 2217,2284 ---- } + // @pymethod |win32print|DeletePrinterDriver|Removes the specified printer driver from a server + static PyObject *PyDeletePrinterDriver(PyObject *self, PyObject *args) + { + PyObject *ret=NULL; + PyObject *observername, *obenvironment, *obdrivername; + WCHAR *servername=NULL, *environment=NULL, *drivername=NULL; + // @pyparm string/<o PyUnicode>|Server||Name of print server, use None for local machine + // @pyparm string/<o PyUnicode>|Environment||Environment - eg 'Windows NT x86' - use None for current client environment + // @pyparm string/<o PyUnicode>|DriverName||Name of driver to remove + // @comm Does not delete associated driver files - use <om win32print.DeletePrinterDriverEx> if this is required + if (PyArg_ParseTuple(args,"OOO:DeletePrinterDriver", &observername, &obenvironment, &obdrivername) + &&PyWinObject_AsWCHAR(observername, &servername, TRUE) + &&PyWinObject_AsWCHAR(obenvironment, &environment, TRUE) + &&PyWinObject_AsWCHAR(obdrivername, &drivername, FALSE)) + if (DeletePrinterDriverW(servername, environment, drivername)){ + Py_INCREF(Py_None); + ret=Py_None; + } + else + PyWin_SetAPIError("DeletePrinterDriver"); + + if (servername!=NULL) + PyWinObject_FreeWCHAR(servername); + if (environment!=NULL) + PyWinObject_FreeWCHAR(environment); + if (drivername!=NULL) + PyWinObject_FreeWCHAR(drivername); + return ret; + } + + // @pymethod |win32print|DeletePrinterDriverEx|Deletes a printer driver and its associated files + static PyObject *PyDeletePrinterDriverEx(PyObject *self, PyObject *args) + { + PyObject *ret=NULL; + PyObject *observername, *obenvironment, *obdrivername; + WCHAR *servername=NULL, *environment=NULL, *drivername=NULL; + DWORD deleteflag, versionflag; + CHECK_PFN(DeletePrinterDriverEx); + // @pyparm string/<o PyUnicode>|Server||Name of print server, use None for local machine + // @pyparm string/<o PyUnicode>|Environment||Environment - eg 'Windows NT x86' - use None for current client environment + // @pyparm string/<o PyUnicode>|DriverName||Name of driver to remove + // @pyparm int|DeleteFlag||Combination of DPD_DELETE_SPECIFIC_VERSION, DPD_DELETE_UNUSED_FILES, and DPD_DELETE_ALL_FILES + // @pyparm int|VersionFlag||Can be 0,1,2, or 3. Only used if DPD_DELETE_SPECIFIC_VERSION is specified in DeleteFlag + if (PyArg_ParseTuple(args,"OOOll:DeletePrinterDriverEx", &observername, &obenvironment, &obdrivername, + &deleteflag, &versionflag) + &&PyWinObject_AsWCHAR(observername, &servername, TRUE) + &&PyWinObject_AsWCHAR(obenvironment, &environment, TRUE) + &&PyWinObject_AsWCHAR(obdrivername, &drivername, FALSE)) + if ((*pfnDeletePrinterDriverEx)(servername, environment, drivername, deleteflag, versionflag)){ + Py_INCREF(Py_None); + ret=Py_None; + } + else + PyWin_SetAPIError("DeletePrinterDriverEx"); + + if (servername!=NULL) + PyWinObject_FreeWCHAR(servername); + if (environment!=NULL) + PyWinObject_FreeWCHAR(environment); + if (drivername!=NULL) + PyWinObject_FreeWCHAR(drivername); + return ret; + } + /* List of functions exported by this module */ // @module win32print|A module, encapsulating the Windows Win32 API. *************** *** 2259,2262 **** --- 2325,2330 ---- {"AddPrinter", PyAddPrinter, 1}, //@pymeth AddPrinter|Adds a new printer on a server {"DeletePrinter", PyDeletePrinter, 1}, //@pymeth DeletePrinter|Deletes an existing printer + {"DeletePrinterDriver", PyDeletePrinterDriver,1}, //@pymeth DeletePrinterDriver|Deletes the specified driver from a server + {"DeletePrinterDriverEx", PyDeletePrinterDriverEx,1}, //@pymeth DeletePrinterDriverEx|Deletes a printer driver and associated files { NULL } }; *************** *** 2405,2408 **** --- 2473,2481 ---- AddConstant(dict, "PORT_TYPE_NET_ATTACHED",PORT_TYPE_NET_ATTACHED); + // DeletePrinterDriverEx DeleteFlag + AddConstant(dict, "DPD_DELETE_SPECIFIC_VERSION",DPD_DELETE_SPECIFIC_VERSION); + AddConstant(dict, "DPD_DELETE_UNUSED_FILES",DPD_DELETE_UNUSED_FILES); + AddConstant(dict, "DPD_DELETE_ALL_FILES",DPD_DELETE_ALL_FILES); + HMODULE hmodule=LoadLibrary("winspool.drv"); if (hmodule!=NULL){ *************** *** 2418,2421 **** --- 2491,2495 ---- pfnGetPrintProcessorDirectory=(GetPrintProcessorDirectoryfunc)GetProcAddress(hmodule,"GetPrintProcessorDirectoryW"); pfnGetPrinterDriverDirectory=(GetPrintProcessorDirectoryfunc)GetProcAddress(hmodule,"GetPrinterDriverDirectoryW"); + pfnDeletePrinterDriverEx=(DeletePrinterDriverExfunc)GetProcAddress(hmodule,"DeletePrinterDriverExW"); } dummy_tuple=PyTuple_New(0); |