diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
--- Python-3.8.0-orig/configure.ac	2019-10-22 10:00:56.583336100 +0300
+++ Python-3.8.0/configure.ac	2019-10-22 10:00:58.938940200 +0300
@@ -3181,6 +3181,13 @@
 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
+
 # Templates for things AC_DEFINEd more than once.
 # For a single AC_DEFINE, no template is needed.
 AH_TEMPLATE(_REENTRANT,
diff -Naur Python-3.8.0-orig/Modules/Setup.config.in Python-3.8.0/Modules/Setup.config.in
--- Python-3.8.0-orig/Modules/Setup.config.in	2019-10-22 10:00:57.800138200 +0300
+++ Python-3.8.0/Modules/Setup.config.in	2019-10-22 10:00:59.328940900 +0300
@@ -6,3 +6,6 @@
 # init system calls(posix/nt/...) for INITFUNC (used by makesetup)
 @INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c
 
+# build-in modules for windows platform:
+@USE_WIN32_MODULE@winreg ../PC/winreg.c
+
diff -Naur Python-3.8.0-orig/PC/winreg.c Python-3.8.0/PC/winreg.c
--- Python-3.8.0-orig/PC/winreg.c	2019-10-14 16:34:47.000000000 +0300
+++ Python-3.8.0/PC/winreg.c	2019-10-22 10:00:59.734541600 +0300
@@ -17,6 +17,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);
