Thread: [pywin32-checkins] pywin32/win32/src win32apimodule.cpp,1.72,1.73
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-02-27 02:58:51
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32520/win32/src Modified Files: win32apimodule.cpp Log Message: Add RegCopyTree and RegDeleteTree Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** win32apimodule.cpp 20 Feb 2007 10:31:15 -0000 1.72 --- win32apimodule.cpp 27 Feb 2007 02:58:47 -0000 1.73 *************** *** 71,74 **** --- 71,78 ---- typedef LONG (WINAPI *RegOpenKeyTransactedfunc)(HKEY,LPWSTR,DWORD,REGSAM,PHKEY,HANDLE,PVOID); static RegOpenKeyTransactedfunc pfnRegOpenKeyTransacted = NULL; + typedef LONG (WINAPI *RegCopyTreefunc)(HKEY,LPWSTR,HKEY); + static RegCopyTreefunc pfnRegCopyTree = NULL; + typedef LONG (WINAPI *RegDeleteTreefunc)(HKEY,LPWSTR); + static RegDeleteTreefunc pfnRegDeleteTree = NULL; *************** *** 2547,2550 **** --- 2551,2587 ---- // If the function fails, an exception is raised. } + + // @pymethod |win32api|RegCopyTree|Copies an entire registry key to another location + // @comm Accepts keyword args. + // @comm Requires Vista or later. + static PyObject *PyRegCopyTree(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(RegCopyTree); + static char *keywords[]={"KeySrc","SubKey","KeyDest", NULL}; + HKEY src, dst; + PyObject *obsrc, *obsubkey, *obdst, *ret=NULL; + WCHAR *subkey=NULL; + long rc; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:RegCopyTree", keywords, + &obsrc, // @pyparm <o PyHKEY>|KeySrc||Registry key to be copied + &obsubkey, // @pyparm <o PyUnicode>|SubKey||Subkey to be copied, can be None + &obdst)) // @pyparm <o PyHKEY>|KeyDest||The destination key + return NULL; + if (PyWinObject_AsHKEY(obsrc, &src) + &&PyWinObject_AsWCHAR(obsubkey, &subkey, TRUE) + &&PyWinObject_AsHKEY(obdst, &dst)){ + rc=(*pfnRegCopyTree)(src, subkey, dst); + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegCopyTree", rc); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PyWinObject_FreeWCHAR(subkey); + return ret; + } + // @pymethod <o PyHKEY>|win32api|RegCreateKey|Creates the specified key, or opens the key if it already exists. static PyObject * *************** *** 2699,2703 **** PyObject *obKey, *obsubKey, *obtrans, *ret=NULL; PVOID extparam=NULL; // Reserved, ignore for now ! WCHAR *subKey=NULL, *class_name=NULL; REGSAM access=0; DWORD reserved=0; --- 2736,2740 ---- PyObject *obKey, *obsubKey, *obtrans, *ret=NULL; PVOID extparam=NULL; // Reserved, ignore for now ! WCHAR *subKey=NULL; REGSAM access=0; DWORD reserved=0; *************** *** 2727,2730 **** --- 2764,2797 ---- } + // @pymethod |win32api|RegDeleteTree|Recursively deletes a key's subkeys and values + // @comm Accepts keyword args. + // @comm Requires Vista or later. + static PyObject *PyRegDeleteTree(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(RegDeleteTree); + HKEY hKey; + PyObject *obKey, *obsubKey, *ret=NULL; + WCHAR *subKey=NULL; + long rc; + static char *keywords[]={"Key","SubKey", NULL}; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:RegDeleteTree", keywords, + &obKey, // @pyparm <o PyHKEY>|Key||Handle to a registry key + &obsubKey)) // @pyparm <o PyUnicode>|SubKey||Name of subkey to be deleted, or None for all subkeys and values + return NULL; + + if (PyWinObject_AsHKEY(obKey, &hKey) + &&PyWinObject_AsWCHAR(obsubKey, &subKey, TRUE)){ + rc=(*pfnRegDeleteTree)(hKey, subKey); + if (rc!=ERROR_SUCCESS) + PyWin_SetAPIError("RegDeleteTree", rc); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + } + PyWinObject_FreeWCHAR(subKey); + return ret; + } + // @pymethod |win32api|RegDeleteValue|Removes a named value from the specified registry key. static PyObject * *************** *** 5534,5537 **** --- 5601,5605 ---- {"RegCloseKey", PyRegCloseKey, 1}, // @pymeth RegCloseKey|Closes a registry key. {"RegConnectRegistry", PyRegConnectRegistry, 1}, // @pymeth RegConnectRegistry|Establishes a connection to a predefined registry handle on another computer. + {"RegCopyTree", (PyCFunction)PyRegCopyTree, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCopyTree|Copies an entire registry key to another location {"RegCreateKey", PyRegCreateKey, 1}, // @pymeth RegCreateKey|Creates the specified key, or opens the key if it already exists. {"RegCreateKeyEx", (PyCFunction)PyRegCreateKeyEx, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCreateKeyEx|Extended version of RegCreateKey *************** *** 5539,5542 **** --- 5607,5611 ---- {"RegDeleteKey", PyRegDeleteKey, 1}, // @pymeth RegDeleteKey|Deletes the specified key. {"RegDeleteKeyTransacted",(PyCFunction)PyRegDeleteKeyTransacted, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegDeleteKeyTransacted|Deletes a registry key as part of a transaction + {"RegDeleteTree", (PyCFunction)PyRegDeleteTree, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegDeleteTree|Recursively deletes a key's subkeys and values {"RegDeleteValue", PyRegDeleteValue, 1}, // @pymeth RegDeleteValue|Removes a named value from the specified registry key. {"RegEnumKey", PyRegEnumKey, 1}, // @pymeth RegEnumKey|Enumerates subkeys of the specified open registry key. *************** *** 5718,5721 **** --- 5787,5792 ---- pfnRegOpenKeyTransacted=(RegOpenKeyTransactedfunc)GetProcAddress(hmodule, "RegOpenKeyTransactedW"); pfnRegDeleteKeyTransacted=(RegDeleteKeyTransactedfunc)GetProcAddress(hmodule, "RegDeleteKeyTransactedW"); + pfnRegCopyTree=(RegCopyTreefunc)GetProcAddress(hmodule, "RegCopyTreeW"); + pfnRegDeleteTree=(RegDeleteTreefunc)GetProcAddress(hmodule, "RegDeleteTreeW"); } |