From: Martin Panter Date: 1469767898 0 Issue #17600: MINGW: build-in winreg module Patch by Roumen Petrov. diff -r 11ed7c49f5df Modules/Setup.config.in --- a/Modules/Setup.config.in Fri Jul 29 04:00:44 2016 +0000 +++ b/Modules/Setup.config.in Fri Jul 29 04:51:46 2016 +0000 @@ -9,5 +9,8 @@ # The signal module @USE_SIGNAL_MODULE@_signal signalmodule.c +# build-in modules for windows platform: +@USE_WIN32_MODULE@winreg ../PC/winreg.c + # The rest of the modules previously listed in this file are built # by the setup.py script in Python 2.1 and later. diff -r 11ed7c49f5df PC/winreg.c --- a/PC/winreg.c Fri Jul 29 04:00:44 2016 +0000 +++ b/PC/winreg.c Fri Jul 29 04:51:46 2016 +0000 @@ -16,6 +16,25 @@ #include "structmember.h" #include "windows.h" +#ifndef SIZEOF_HKEY +/* used only here */ +#if defined(MS_WIN64) +# define SIZEOF_HKEY 8 +#elif defined(MS_WIN32) +# define SIZEOF_HKEY 4 +#else +# error "SIZEOF_HKEY is not defined" +#endif +#endif + +#ifndef REG_LEGAL_CHANGE_FILTER +#define REG_LEGAL_CHANGE_FILTER (\ + REG_NOTIFY_CHANGE_NAME |\ + REG_NOTIFY_CHANGE_ATTRIBUTES |\ + REG_NOTIFY_CHANGE_LAST_SET |\ + REG_NOTIFY_CHANGE_SECURITY ) +#endif + static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); static BOOL clinic_HKEY_converter(PyObject *ob, void *p); static PyObject *PyHKEY_FromHKEY(HKEY h); @@ -973,6 +992,10 @@ REGSAM access, int reserved) /*[clinic end generated code: output=01378d86ad3eb936 input=711d9d89e7ecbed7]*/ { +#ifdef KEY_WOW64_64KEY +/* KEY_WOW64_64KEY is defined for _WIN32_WINNT >= 0x0502, + * i.e. Windows Server 2003 with SP1, Windows XP with SP2 + * and not supported on w2k. */ HMODULE hMod; typedef LONG (WINAPI *RDKEFunc)(HKEY, const wchar_t*, REGSAM, int); RDKEFunc pfn = NULL; @@ -996,6 +1019,11 @@ if (rc != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx"); Py_RETURN_NONE; +#else /*def KEY_WOW64_64KEY*/ + PyErr_SetString(PyExc_NotImplementedError, + "not implemented on this platform"); + return NULL; +#endif } /*[clinic input] diff -r 11ed7c49f5df configure --- a/configure Fri Jul 29 04:00:44 2016 +0000 +++ b/configure Fri Jul 29 04:51:46 2016 +0000 @@ -647,6 +647,7 @@ USE_THREAD_MODULE SIGNAL_OBJS USE_SIGNAL_MODULE +USE_WIN32_MODULE TCLTK_LIBS TCLTK_INCLUDES LIBFFI_INCLUDEDIR @@ -10052,6 +10053,14 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_dbmliborder" >&5 $as_echo "$with_dbmliborder" >&6; } + +# Determine if windows modules should be used. + +USE_WIN32_MODULE='#' +case $host in + *-*-mingw*) USE_WIN32_MODULE=;; +esac + # Determine if signalmodule should be used. diff -r 11ed7c49f5df configure.ac --- a/configure.ac Fri Jul 29 04:00:44 2016 +0000 +++ b/configure.ac Fri Jul 29 04:51:46 2016 +0000 @@ -2775,6 +2775,14 @@ fi]) AC_MSG_RESULT($with_dbmliborder) + +# Determine if windows modules should be used. +AC_SUBST(USE_WIN32_MODULE) +USE_WIN32_MODULE='#' +case $host in + *-*-mingw*) USE_WIN32_MODULE=;; +esac + # Determine if signalmodule should be used. AC_SUBST(USE_SIGNAL_MODULE) AC_SUBST(SIGNAL_OBJS)