@@ -979,7 +979,9 @@ winreg_DeleteKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key)
979979 (Py_ssize_t )0 ) < 0 ) {
980980 return NULL ;
981981 }
982- rc = RegDeleteKeyW (key , sub_key );
982+ Py_BEGIN_ALLOW_THREADS
983+ rc = RegDeleteKeyW (key , sub_key );
984+ Py_END_ALLOW_THREADS
983985 if (rc != ERROR_SUCCESS )
984986 return PyErr_SetFromWindowsErrWithFunction (rc , "RegDeleteKey ");
985987 Py_RETURN_NONE ;
@@ -1000,7 +1002,10 @@ winreg.DeleteKeyEx
10001002 reserved: int = 0
10011003 A reserved integer, and must be zero. Default is zero.
10021004
1003- Deletes the specified key (64-bit OS only).
1005+ Deletes the specified key (intended for 64-bit OS).
1006+
1007+ While this function is intended to be used for 64-bit OS, it is also
1008+ available on 32-bit systems.
10041009
10051010This method can not delete keys with subkeys.
10061011
@@ -1013,34 +1018,17 @@ static PyObject *
10131018winreg_DeleteKeyEx_impl (PyObject * module , HKEY key ,
10141019 const Py_UNICODE * sub_key , REGSAM access ,
10151020 int reserved )
1016- /*[clinic end generated code: output=52a1c8b374ebc003 input=711d9d89e7ecbed7 ]*/
1021+ /*[clinic end generated code: output=52a1c8b374ebc003 input=a3186db079b3bf85 ]*/
10171022{
1018- HMODULE hMod ;
1019- typedef LONG (WINAPI * RDKEFunc )(HKEY , const wchar_t * , REGSAM , int );
1020- RDKEFunc pfn = NULL ;
10211023 long rc ;
1022-
10231024 if (PySys_Audit ("winreg.DeleteKey" , "nun" ,
10241025 (Py_ssize_t )key , sub_key ,
10251026 (Py_ssize_t )access ) < 0 ) {
10261027 return NULL ;
10271028 }
1028- /* Only available on 64bit platforms, so we must load it
1029- dynamically. */
10301029 Py_BEGIN_ALLOW_THREADS
1031- hMod = GetModuleHandleW (L"advapi32.dll" );
1032- if (hMod )
1033- pfn = (RDKEFunc )GetProcAddress (hMod , "RegDeleteKeyExW" );
1030+ rc = RegDeleteKeyExW (key , sub_key , access , reserved );
10341031 Py_END_ALLOW_THREADS
1035- if (!pfn ) {
1036- PyErr_SetString (PyExc_NotImplementedError ,
1037- "not implemented on this platform" );
1038- return NULL ;
1039- }
1040- Py_BEGIN_ALLOW_THREADS
1041- rc = (* pfn )(key , sub_key , access , reserved );
1042- Py_END_ALLOW_THREADS
1043-
10441032 if (rc != ERROR_SUCCESS )
10451033 return PyErr_SetFromWindowsErrWithFunction (rc , "RegDeleteKeyEx ");
10461034 Py_RETURN_NONE ;
0 commit comments