From f80df5a0fa6f5fdb999e9b9c13d9574468c99d77 Mon Sep 17 00:00:00 2001 From: Roumen Petrov Date: Sat, 23 Feb 2013 20:08:15 +0200 Subject: [PATCH 11/16] MINGW: build-in windows modules (winreg) --- Modules/Setup.config.in | 3 +++ PC/winreg.c | 28 ++++++++++++++++++++++++++++ configure.ac | 8 ++++++++ 3 files changed, 39 insertions(+) diff --git a/Modules/Setup.config.in b/Modules/Setup.config.in index 3bcb0ba..e41345d 100644 --- a/Modules/Setup.config.in +++ b/Modules/Setup.config.in @@ -12,5 +12,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 --git a/PC/winreg.c b/PC/winreg.c index a2511d5..75349ac7 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -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 PyObject *PyHKEY_FromHKEY(HKEY h); static BOOL PyHKEY_Close(PyObject *obHandle); @@ -1079,6 +1098,10 @@ PyDeleteKey(PyObject *self, PyObject *args) static PyObject * PyDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs) { +#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. */ HKEY hKey; PyObject *key; HMODULE hMod; @@ -1115,6 +1138,11 @@ PyDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs) return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx"); Py_INCREF(Py_None); return Py_None; +#else /*def KEY_WOW64_64KEY*/ + PyErr_SetString(PyExc_NotImplementedError, + "not implemented on this platform"); + return NULL; +#endif } static PyObject * diff --git a/configure.ac b/configure.ac index d000a62..fb67bf5 100644 --- a/configure.ac +++ b/configure.ac @@ -2404,6 +2404,14 @@ else 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) -- 1.7.12.1