Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.15 diff -u -r1.15 _winreg.c --- _winreg.c 30 Nov 2003 22:01:43 -0000 1.15 +++ _winreg.c 22 Jun 2004 10:13:28 -0000 @@ -1032,30 +1032,26 @@ int index; long rc; PyObject *retStr; + FILETIME filetime; char *retBuf; - DWORD len; + DWORD len = 255; + char tmpbuf[255]; /* Max key name according to Platform SDK */ if (!PyArg_ParseTuple(args, "Oi:EnumKey", &obKey, &index)) - return NULL; + return NULL; if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) - return NULL; - - if ((rc = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, &len, - NULL, NULL, NULL, NULL, NULL, NULL)) - != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryInfoKey"); - ++len; /* include null terminator */ - retStr = PyString_FromStringAndSize(NULL, len); - if (retStr == NULL) - return NULL; - retBuf = PyString_AS_STRING(retStr); - - if ((rc = RegEnumKey(hKey, index, retBuf, len)) != ERROR_SUCCESS) { - Py_DECREF(retStr); - return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKey"); + return NULL; + + /* Get the key */ + rc = RegEnumKeyEx( hKey, index, tmpbuf, &len, NULL, NULL, NULL , &filetime); + if( rc != ERROR_SUCCESS ) + { + return PyErr_SetFromWindowsErrWithFunction(rc, + "RegQueryInfoKey"); } - _PyString_Resize(&retStr, strlen(retBuf)); + + retStr = PyString_FromStringAndSize(tmpbuf, len); + return retStr; }